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

The 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 parameters

Parameter

Description

messages

A list of messages.

messages /account_sid

Account identifier.

messages /number_sid

Number identifier.

messages /text

Message text.

messages /created

Message creation date.

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.

Description

A parameter describing how many records are returned at once.

The default and maximum value is 20.

Description

URI to the previous part of the list.

Description

URI to the next part of the list.

Description

A list of messages.

Description

Account identifier.

Description

Number identifier

Description

Message text.

Description

Message creation date.

Description

Message direction.

Either inbound oroutbound.

Description

Recipient’s phone number.

Description

Sender’s phone number.

Description

The cost of sending the message (in EUR).

Description

Message identifier.

Description

The current message status.

Can be one of the following:

queued,sentreceived,

deliveredfailed.

Description

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

Description

Can be one of the following: sms, telegram

Description

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

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

Parameter

Description

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

Description

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

Description

Message identifier.

Description

Message Account identifier. date.

Description

Account identifier.

Description

Recipient’s phone number.

Description

Sender’s phone number.

Description

Message direction.

Either inbound or outbound.

Description

The current message status.

Can be one of the following:

queuedsentreceived,

deliveredfailed.

Description

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