Skip to content

List Messages

Request

Retrieve a list of SMS messages for the logged in user.

Explanation of Return Value

The data object in the return result contains the following keys:

KeyDescription
messagesAn array of messages. Each message is represented by an object. The format of this object is discussed below.
totThe total number of messages returned in the messages array.
optionsInidicates if any cached data should be cleared. See the Data Caching documentation for more information.
Message Objects

Each object in the messages array represents a single message, and includes the following keys that an application may be interested in:

KeyDescription
idThe ID of the message. This is the ID that should be passed to the lastId parameter in subsequent API calls to retrieve only newer messages.
dateThe time that the message was sent, represented as the number of seconds since the UNIX epoch.
bnumThe AVANSER phone number that the message was sent from/to, in AVANSER format (this is always the phone number of the API user).
externalThe non-AVANSER phone number involved in the conversation, in AVANSER format.
textThe content of the message.
directionThe direction of the message (in or out). in indicates that the message was sent from the external number to the bnum number. out indicates that the message was sent from the bnum number to the external number.

Note: Messages in the messages array are returned in reverse-chronological order, with the newest messages appearing first in the array. The logged in user may have messages for multiple BNUMS, and each BNUM may have messages for mutliple external numbers. The messages from a single conversation aren't necessarily grouped together in the array, and it is the responsibility of the application to parse the array and display the messages in the desired format. Also note that when subsequent API calls are made to retrieve new messages, the new return result may include BNUMs or external numbers that didn't appear in the previous result.

When making a subsequent API call to retrieve newer messages, the application should pass the highest ID value in the lastId parameter.

Errors

Error CodeError TypeError Message
-1021GET-MESSAGES-FAILEDUnable to retreive the message list

This is a generic error returned if the messages cannot be retrieved for an unspecified reason.

Security
accessToken
Query
lastIdnumber

The ID of the most recently retrieved message. If provided, only newer messages will be retrieved. If omitted, all messages for the logged in user will be retrieved.

curl -i -X GET \
  'https://p3.avanser.com/app/messages?lastId=0&token=YOUR_API_KEY_HERE'

Responses

SMS messages for the logged in user.

Bodyapplication/json
timestampintegerrequired

The time that the API response left the server, represented as the number of seconds since the UNIX epoch.

Example:1508903167
exectionnumber

The number of seconds that it took to process the API request.

Example:0.00041531896591187
errorbooleanrequired

Boolean indicating whether there was an error returned by the API request.

Example:false
dataobjectrequired

The data returned by the API. The format varies depending on the API function that was called.

Response
{ "timestamp": 1508970922, "exection": 0.00095471692085266, "error": false, "data": { "messages": [ … ], "tot": 2, "options": null } }