NetSfere Public API

Introduction

NetSfere provides a public API for performing basic functions. The API accepts its requests over HTTPS and generally returns JSON formatted data.

To use this API, create a NetSfere organization and then use your organization's admin control panel to provision a dedicated user for connecting to the API. Pass this user's account credentials in the HTTPS request.

This documentation is available in the following additional languages:

By using this API, you agree to abide by NetSfere's Terms of Service.

Authorizing API Access

NetSfere's public API is disabled by default. To enable access for particular users within your NetSfere organization, ask your NetSfere administrator to enable API access as follows:

  1. Login to admin.netsfere.com.
  2. Click or tap on Users and select the desired user.
  3. Choose Modify User from the Actions menu.
  4. Set Enable Network API to Yes.
  5. Click or tap the Save button.

Your admin may wish to provision one or more dedicated NetSfere user accounts for accessing the API.

API Endpoints

See below for a description of the available API endpoints.

get

Description

Enables an external client to retrieve text messages or attachment meta data. You must call this endpoint via HTTPS using the POST method.

Additionally, this endpoint may be used to poll for the arrival of new messages. Message IDs increase for each new message, so passing the message ID of a previous message (see the msgId parameter) returns new messages created since the previous message.

Parameters

This endpoint requires the following parameters:

Parameter Description
email The email address of the NetSfere user who is retrieving the message content. This must be an address of an active user in your organization.
password The password for the NetSfere user who is retrieving the message content.

The following parameters are optional and may be passed in any combination to refine the data returned by this endpoint. If you pass multiple parameters, this endpoint combines them using a logical "AND" operation.

For example, if you pass "27848" for convId and "212619" for msgId, this endpoint returns zero or more messages from the conversation whose conversation ID is 27848 that were created after the message whose message ID is 212619.

Parameter Description
convId

The numeric conversation ID of an existing NetSfere conversation. This parameter is optional. If present, the endpoint returns only messages in the specified conversation.

You can obtain the conversation ID for a conversation by viewing it at web.netsfere.com and extracting the ID from the rightmost portion of the URL. Example:

https://web.netsfere.com/#chat/27848

In the above URL, the conversation ID is 27848.

msgId

Return only messages whose message ID is greater than msgId.

NetSfere guarantees that each new message created receives a unique message ID that is greater than the message ID assigned to any previous message. Therefore, you can use this parameter to poll for messages created since some previous known message.

For example, if you've previously received a message whose message ID is 212619, you can pass "212619" for this parameter to retrieve only messages created since that previous message.

Pass zero for this parameter to retrieve all messages.

msgLimit

Return only the first msgLimit messages.

For example, if the get endpoint locates 3 messages that match the criteria specified in the HTTP call and you pass "2" for msgLimit, this endpoint will return the 2 oldest messages. The third and most recent message will not be present in the response.

Response

If successful, this web service returns an HTTP 200 response whose body contains a JSON-encoded array of objects, where each object represents a single message:

[
   {
      "msgId": 212619,
      "convId": 27848,
      "created": 1516655475,
      "senderEmail": "user1@email.com",
      "msgType": "text",
      "msgText": "A man's home is his castle.",
      "attachment": null,
      "quotedMsgId": 0,
      "locationData": null,
      "isForwarded": false,
      "priority": "normal",
      "isDeleted": false
   },
   {
      "msgId": 212620,
      "convId": 27848,
      "created": 1516656257,
      "senderEmail": "user1@email.com",
      "msgType": "attachment",
      "msgText": "",
      "attachment": {
         "attachmentId":"5a66542c8e77a",
         "fileName":"castle.jpg",
         "fileSize":242560,
         "mimeType":"image\/jpeg"},
      "quotedMsgId": 0,
      "locationData": null,
      "isForwarded": true,
      "priority": "normal",
      "isDeleted": false
   },
   {
      "msgId": 212621,
      "convId": 27848,
      "created": 1516666257,
      "senderEmail": "user1@email.com",
      "msgType": "location",
      "msgText": "loc:42.1341247,-88.0035324",
      "attachment": null,
      "quotedMsgId": 0,
      "locationData": {
         "address": "Infinite Convergence, North Wilke Road, Arlington Heights, IL, USA",
         "isMyLocation": true
      },
      "isForwarded": false,
      "priority": "normal",
      "isDeleted": false
   }
]

If the message contains an attachment, the attachment element contains a second-level JSON object of the form shown in the second message above. You must call the getfile endpoint to retrieve the attachment's binary data.

If an error occurs, this web service returns an HTTP 4XX or HTTP 5XX response whose body contains a JSON object of the following form:

{
   "error": "Missing parameter: \"email\""
}

Example

Here's how to call this endpoint with curl:

curl -i 'https://api.netsfere.com/get' \
--data 'email=user1@email.com&password=123&msgId=212619'
getfile

Description

Enables an external client to retrieve a message attachment. You must call this endpoint via HTTPS using the POST method.

Parameters

This endpoint requires the following parameters:

Parameter Description
email The email address of the NetSfere user who is retrieving the message content. This must be an address of an active user in your organization.
password The password for the NetSfere user who is retrieving the message content.

The following parameters are required to uniquely identify the attachment to retrieve. Either attachmentId or both convId and msgId must be specified.

attachmentId A numeric value that uniquely identifies the attachment to retrieve. This value typically comes from a previous call to the get endpoint.
convId A numeric value that along with msgId uniquely identifies the attachment to retrieve. This value typically comes from a previous call to the get or sendfile endpoints.
msgId A numeric value that along with convId uniquely identifies the attachment to retrieve. This value typically comes from a previous call to the get or sendfile endpoints.

Response

If successful, this web service returns an HTTP 200 response and the attachment's raw binary data.

If an error occurs, this web service returns an HTTP 4XX or HTTP 5XX response whose body contains a JSON object of the following form:

{
   "error": "Missing parameter: \"email\""
}

Example

Here's how to call this endpoint with curl:

curl -i 'https://api.netsfere.com/getfile' \
--data 'email=user1@email.com&password=123&attachmentId=5a66542c8e77a' -o castle.jpg

or:

curl -i 'https://api.netsfere.com/getfile' \
--data 'email=user1@email.com&password=123&convId=1000&msgId=123456' -o castle.jpg
send

Description

Enables an external client to send a message in a new conversation or an existing conversation. You must call this endpoint via HTTPS using the POST method.

Parameters

This endpoint requires the following parameters:

Parameter Description
email The email address of the NetSfere user who is sending the message. This must be an address of an active user in your organization.
password The password for the NetSfere user who is sending the message.
msgText The UTF-8 encoded text of the message.
msgPriority NetSfere clients supports only 0 (Normal) and 3 (Critical) message priorities. Server rejects message priorities other than 0 and 3, as invalid request and message priorities shall be considered only for emergency broadcast channels.

To create a new conversation containing the message, pass the following additional parameters:

Parameter Description
convTitle The title of the NetSfere conversation. Omit this parameter to use the names of the participants as the conversation title.
participants A comma-separated list of email addresses identifying the users who are to be participants. Omit this parameter to create a conversation with the sender as its only participant.

To append the message to an existing conversation, pass the following parameters:

Parameter Description
convId

The numeric conversation ID of an existing conversation.

You can obtain the conversation ID for a conversation by viewing it at web.netsfere.com and extracting the ID from the rightmost portion of the URL. Example:

https://web.netsfere.com/#chat/27848

In the above URL, the conversation ID is 27848.

Response

If successful, this web service returns an HTTP 200 response whose body contains a JSON object of the following form:

{
   "convId": 1000,
   "msgId": 123456
}

The convId element contains the numeric conversation ID associated with the message. The msgId element contains the numeric message ID assigned to the message.

If an error occurs, this web service returns an HTTP 4XX or HTTP 5XX response whose body contains a JSON object of the following form:

{
   "error": "Missing parameter: \"email\""
}

Example

Here's how to call this endpoint with curl:

curl -i 'https://api.netsfere.com/send' \
--data 'email=user1@email.com&password=123&msgText=This is a test.&convTitle=Hello World!&participants=user2@email.com,user3@email.com'
sendfile

Description

Enables an external client to send a file as an attachment in a new conversation or an existing conversation. You must call this endpoint via HTTPS using the POST method with the Content-Type header set to multipart/form-data.

Parameters

This endpoint requires the following parameters:

Parameter Description
email The email address of the NetSfere user who is sending the file as an attachment. This must be an address of an active user in your organization.
password The password for the NetSfere user who is sending the file.
uploadFile The name and binary content of the file to send. These must be encoded using the multipart/form-data format as specified by RFC2388.
msgText Optional UTF-8 encoded text to send with the attachment.
priority NetSfere clients supports only 0 (Normal) and 3 (Critical) message priorities. Server rejects message priorities other than 0 and 3, as invalid request and message priorities shall be considered only for emergency broadcast channels.

To create a new conversation containing the file as an attachment, you must also pass the following additional parameters:

Parameter Description
convTitle The title of the NetSfere conversation. Omit this parameter to use the names of the participants as the conversation title.
participants A comma-separated list of email addresses identifying the users who are to be participants.

To append the file as an attachment to an existing conversation, you must also pass the following parameters:

Parameter Description
convId

The numeric conversation ID of an existing conversation.

You can obtain the conversation ID for a conversation by viewing it at web.netsfere.com and extracting the ID from the rightmost portion of the URL. Example:

https://web.netsfere.com/#chat/27848

In the above URL, the conversation ID is 27848.

Response

If successful, this web service returns an HTTP 200 response whose body contains a JSON object of the following form:

{
   "convId": 1000,
   "msgId": 123456
}

The convId element contains the numeric conversation ID associated with the message containing the attachment. The msgId element contains the numeric message ID assigned to the message.

If an error occurs, this web service returns an HTTP 4XX or HTTP 5XX response whose body contains a JSON object of the following form:

{
   "error": "Missing parameter: \"email\""
}

This endpoint does not support thumbnail generation, so image attachments will appear to recipients with a generic attachment icon.

Example

Here's how to call this endpoint with curl:

curl -i 'https://api.netsfere.com/sendfile' \
-F 'email=user1@email.com' \
-F 'password=123' \
-F 'convTitle=Hello World!' \
-F 'participants=user2@email.com,user3@email.com' \
-F 'msgText=My example' \
-F 'uploadFile=@path/to/my/example.png'
webhook

Description

Enables an external client to register a callback URL. When an important event (such as the arrival of a new message) occurs in the caller's NetSfere account, NetSfere calls this URL.

You must call this endpoint via HTTPS using the POST method (to register a new callback URL or to replace a previously-registered callback URL) or the DELETE method (to destroy a previously-registered callback URL).

Once you register a webhook, NetSfere continues to call the webhook for each event until one of the following occurs:

  • You remove the webhook using the DELETE method.
  • An admin disables the associated NetSfere account.
  • An admin cancels the NetSfere organization.

NetSfere calls the URL only once for each event and ignores the HTTP response code (including 3XX redirect response codes) returned by the URL.

Parameters

This endpoint requires the following parameters:

Parameter Description
email The email address of the NetSfere user who is creating, updating or deleting the webhook.
password The password for the NetSfere user who is creating, updating or deleting the webhook.

When using the POST method, you must also pass the following additional parameters:

Parameter Description
callbackUrl The URL that NetSfere should call with an HTTPS POST request when an important event (such as the arrival of a new message) occurs in the NetSfere account associated with email. This parameter is required only when using the POST method to create or update a webhook. The callback URL must specify the HTTPS scheme.

Response

If successful, this web service returns an HTTP 200 response whose body contains JSON data of the following form:

OK

If an error occurs, this web service returns an HTTP 4XX or HTTP 5XX response whose body contains a JSON object of the following form:

{
   "error": "Missing parameter: \"email\""
}

Example

Here's how to use curl to register a new webhook with a POST request:

curl -i 'https://api.netsfere.com/webhook' \
--data 'email=user1@email.com&password=123&callbackUrl=https://example.com/my/path?myparam=1000'

Example

Here's how to use curl to delete a previously-registered webhook with a DELETE request:

curl -i -X DELETE 'https://api.netsfere.com/webhook' \
--data 'email=user1@email.com&password=123'

Callback Payload

When an important event (such as the arrival of a new message) occurs, NetSfere will call your callback URL with an HTTPS POST. The body of the POST request will contain JSON-encoded data of the following form:

{
   "convId": 1000,
   "msgId": 123456,
   "senderEmail": "user1@email.com",
   "uuid": "93450918-75fe-11eb-a7fe-00505604a731"
}

The elements in this JSON object are:

Element Description
convId A numeric conversation ID identifying the conversation that contains the new message.
msgId A numeric message ID identifying the new message.
senderEmail The email address of the user who sent the new message.
uuid Unique identifier for this callback event. Helpful when requesting support.

If you wish to retrieve the new message, you may do so by calling the get endpoint with convId and msgId.

NetSfere ignores the response from the callback URL and will not retry the callback if the initial attempt fails.