Retrieve a list of SMS messages for the logged in user.
The data object in the return result contains the following keys:
| Key | Description |
|---|---|
| messages | An array of messages. Each message is represented by an object. The format of this object is discussed below. |
| tot | The total number of messages returned in the messages array. |
| options | Inidicates if any cached data should be cleared. See the Data Caching documentation for more information. |
Each object in the messages array represents a single message, and includes the following keys that an application may be interested in:
| Key | Description |
|---|---|
| id | The 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. |
| date | The time that the message was sent, represented as the number of seconds since the UNIX epoch. |
| bnum | The AVANSER phone number that the message was sent from/to, in AVANSER format (this is always the phone number of the API user). |
| external | The non-AVANSER phone number involved in the conversation, in AVANSER format. |
| text | The content of the message. |
| direction | The 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.
| Error Code | Error Type | Error Message |
|---|---|---|
| -1021 | GET-MESSAGES-FAILED | Unable to retreive the message list |
This is a generic error returned if the messages cannot be retrieved for an unspecified reason.
- Avanser Productionhttps://p3.avanser.com/app/messages
- AVANSER Mock Serverhttps://avanser.redocly.app/_mock/user-api/references/messages
curl -i -X GET \
'https://p3.avanser.com/app/messages?lastId=0&token=YOUR_API_KEY_HERE'SMS messages for the logged in user.
The time that the API response left the server, represented as the number of seconds since the UNIX epoch.
The number of seconds that it took to process the API request.
Boolean indicating whether there was an error returned by the API request.
{ "timestamp": 1508970922, "exection": 0.00095471692085266, "error": false, "data": { "messages": [ … ], "tot": 2, "options": null } }