SMS Chats

In TextMagic, an SMS chat is a convenient grouping of inbound and outbound messages, addressed to specified recipients and arranged as a sorted list. Take a look at the SMS Chat feature in TextMagic Online. Under the hood, this feature is represented by the chat resource.

Get all chats

To get all created chats, use:

GET /api/v2/chats

with these parameters:

Name
Required?
Example
Description
page No

3

Fetch the specified results page. The default is 1.

limit No 25 The number of results per page. The default is 10.

You will receive the standard paginated response:

Parameter
Example
Description
page 3 The current fetched page.
limit 25 The number of results per page.
pageCount 150 The total number of pages.
resources Array of chat resources See the section below for chat resource structure details.

Chat resource structure

Chat is a resource of messages grouped by the sender, sorted chronologically. Below are the parameters returned in the chat resources array.

Parameter
Example
Description
id 43328 Chat ID.
phone 447860021130 Chat partner phone number.
unread 5 Unread incoming messages count.
contact contact resource See Contacts section for details.
updatedAt 2015-01-08T06:13:21+0000 Time when last incoming message arrived at this chat.

Get messages from a specific chat

To get chat messages, use:

GET /api/v2/chats/{phone}

where phone is an E.164 international phone number, and where the command has the following parameters:

Name
Required?
Example
Description
page No

3

Fetch the specified results page. The default is 1.

limit No 25 The number of results per page. The default is 10.

You will receive the standard paginated response:

Parameter
Example
Description
page 3 The current fetched page.
limit 25 The number of results per page.
pageCount 150 The total number of pages.
resources Array of chat messages See the section below for resource format details.

Chat messages resource structure

When requesting messages from a specific chat, you will receive an array of messages with the following parameter structures.

Parameter
Example
Description
id 1782832 message or reply ID (see direction for details).
direction in
out
Message type: inbound or outbound.
sender 447860021130 Sender phone number.
receiver 447624800500 Receiver phone number.
messageTime 2012-11-28T18:38:28+0000 Time when message arrived at TextMagic.
text Test reply Message text.
status d Message status (for chats outbound only).
See message delivery statuses for details.
firstName Charles Contact first name.
lastName Conway Contact last name.

The next step

Now you have learned how to get chat information using the TextMagic API. Please continue with the next section, Sessions, where you will learn more about managing SMS sessions via the TextMagic API.

If you want to learn more about TextMagic’s group messaging and SMS chat, please contact us by emailing support@textmagic.com