Docs

Get message history

https://api.apifonica.com/v2/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.

Request example

XThe following cURL example demonstrates getting message logs.

curl –X GET https://api.apifonica.com/v2/accounts/{accountSID}/messages \
-u {accountSID}:{authToken}

Response example

{
  “messages”: [
    {
      “account_sid”: “{accountSID}”,
      “number_sid”: “{number_sid}”,
      “text”: “Just tried using Apifonica 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",
      "segment_count": 2,
      "channel": "sms",
      "tag": "My_Client1"
    }, … ]
  "limit": 20,
  "prev": null,
  "next": "/v2/accounts/{accountSID}/messages?limit=20&offset=20"
}

Response example

ParameterDescription
messages

A list of messages.

messages /account_sid

Account identifier.

messages /number_sid

Number identifier.

messages /text

Message text.

messages /direction

Message direction.

Either inbound or outbound.

messages /from

Sender’s phone number.

messages /to

Recipient’s phone number.

messages /price

The cost of sending the message (in EUR).

messages /message_sid

Message identifier.

messages/status

The current message status.

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

messages/segment_count

Number of parts in the message. Read more about message limits

messages/channel

Can be one of the following: sms, telegram

messages/tag

Custom optional string field; can be used for custom client message filtering

limit

A parameter describing how many records are returned at once.

The default and maximum value is 20.

prev

URI to the previous part of the list.

next

URI to the next part of the list.

Request example (with filtering)

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

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

Filtering parameters

ParameterDescription
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.

tag

Custom optional string field; can be used for custom client message filtering