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
pageNo

3

Fetch the specified results page. The default is 1.

limitNo25The number of results per page. The default is 10.

You will receive the standard paginated response:

Parameter
Example
Description
page 3The current fetched page.
limit25The number of results per page.
pageCount150The total number of pages.
resourcesArray of chat resourcesSee 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 43328Chat ID.
phone447860021130Chat partner phone number.
unread5Unread incoming messages count.
contactcontact resourceSee Contacts section for details.
updatedAt2015-01-08T06:13:21+0000Time 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
pageNo

3

Fetch the specified results page. The default is 1.

limitNo25The number of results per page. The default is 10.

You will receive the standard paginated response:

Parameter
Example
Description
page 3The current fetched page.
limit25The number of results per page.
pageCount150The total number of pages.
resourcesArray of chat messagesSee 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
id1782832 message or reply ID (see direction for details).
directionin
out
Message type: inbound or outbound.
sender447860021130Sender phone number.
receiver447624800500Receiver phone number.
messageTime2012-11-28T18:38:28+0000Time when message arrived at TextMagic.
textTest replyMessage text.
statusdMessage status (for chats outbound only).
See message delivery statuses for details.
firstNameCharlesContact first name.
lastNameConwayContact 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