Docs

Get message history

/accounts/{accountSID}/messages

Overview

This function gets message history for the account. The return results can be narrowed by specifying such message details as status, direction or creation date. Pagination is also supported.

Input (filtering) parameters

Parameter

Description

offset

A parameter telling where to start returning records from the entire set of results. If you don't include this parameter, the default is to start at record number 0 and then return the number of records specified with the limit parameter.

limit

A parameter describing how many records you want to return all at once. The default and maximum value is 20.

message_sid

Message identifier.

created

Message creation date.

account_sid

Account identifier.

to

Recipient’s phone number.

from

Sender’s phone number.

direction

Message direction.

Either inbound or outbound.

status

The current message status.

Can be one of the following: queued, sent, received, delivered, failed.

Request example

The following cURL example demonstrates getting message logs.

curl –X GET ‘https://api.apico.net/v2/accounts/{accountSID}/messages’ \
-u {accountSID}:{authToken}

Request example (with filtering)

The following cURL request demonstrates getting a list of outbound delivered messages.

curl –X GET ‘https://api.apico.net/v2/accounts/{accountSID}/messages?direction=outbound&status=delivered \
-u {accountSID}:{authToken}

Response example

{
    “offset”: 0, 
    “limit”: 20,
    “next”: “https://api.apico.net/v2/accounts/{accountSID}/messages?limit=20&offset=20”,
    “prev”: null,
           “total”: 50,
    “messages”: [{
        “account_sid”: “{accountSID}”,
	“text”: “Just tried using Apico API to send SMS from the web!”,
	“created”: “Wed, 10 Feb 2016 07:21:01 +0000”,
	“direction”: “outbound”,
	“from”: “447860041755”,
	“to”: “447860041756”,
	“price”: “0.0010”,
	“message_sid”: “{messageSID}”,
        “status”: “delivered”
    }, … ]
}

Response parameters

Parameter

Description

offset

A parameter indicating where the records are started to return from the entire set of results.

limit

A parameter describing how many records are returned at once.

The default and maximum value is 20.

next

URI to the next part of the list.

prev

URI to the previous part of the list.

total

The total number of entries in the returned list.

messages

A list of messages.

messages /message_sid

Message identifier.

messages /created

Message creation date.

messages /account_sid

Account identifier.

messages /to

Recipient’s phone number.

messages /from

Sender’s phone number.

messages /text

Message text.

messages /price

The cost of sending the message (in USD cents).

messages/direction

Message direction.

Either inbound or outbound.

messages/status

The current message status.

Can be one of the following: queued, sent, received, delivered, failed.

messages/status_message

Error details.

It is sent only if the status value is failed.