Get Started

REST API: SMS Messages

The SMS/Messages resource has been deprecated, replaced by the Messages resource, and may be removed in future versions of the Twilio API. Since the Messages resource is a superset of SMS/Messages, we recommend its use going forward.

An SMS Message instance resource represents an inbound or outbound SMS message. Whenever someone sends an SMS message to one of your Twilio numbers, or when you send an SMS message via the REST API or using the <Sms> verb, Twilio creates an SMS Message instance resource and associates it with your account.

The SMS Messages list resource represents the set of SMS messages sent from and received by an account.

SMS Message Instance Resource

This resource represents an individual SMS message.

Resource URI

/2010-04-01/Accounts/{AccountSid}/SMS/Messages/{SMSMessageSid}

Resource Properties

An SMS Message resource is represented by the following properties:

Property Description
Sid A 34 character string that uniquely identifies this resource.
DateCreated The date that this resource was created, given in RFC 2822 format.
DateUpdated The date that this resource was last updated, given in RFC 2822 format.
DateSent The date that the SMS was sent. For incoming messages, this is the date that Twilio received the SMS. The date is given in RFC 2822 format.
AccountSid The unique id of the Account that sent this SMS message.
From The phone number that initiated the message in E.164 format. For incoming messages, this will be the remote phone. For outgoing messages, this will be one of your Twilio phone numbers.
To The phone number that received the message in E.164 format. For incoming messages, this will be one of your Twilio phone numbers. For outgoing messages, this will be the remote phone.
Body The text body of the SMS message. Up to 160 characters long.
Status The status of this SMS message. Either queued, sending, sent,failed, or received.
Direction The direction of this SMS message. inbound for incoming messages, outbound-api for messages initiated via the REST API, outbound-call for messages initiated during a call or outbound-reply for messages initiated in response to an incoming SMS.
Price The amount billed for the message, in the currency associated with the account.
PriceUnit The currency in which Price is measured, in ISO 4127 format (e.g. usd, eur, jpy).
ApiVersion The version of the Twilio API used to process the SMS message.
Uri The URI for this resource, relative to https://api.twilio.com
SMS Status Values

The following are the possible values for the 'Status' parameter.

Status Description
queued The API request to send an SMS message was successful and the message is queued to be sent out.
sending Twilio is in the process of dispatching your message to the nearest upstream carrier in the SMS network.
sent The message was sent to the nearest upstream carrier, and that carrier accepted the message.
failed The message could not be sent, most likely because the "To" number is non-existent.
received On inbound messages only. The message was received by one of your Twilio numbers.

HTTP GET

Returns a single SMS message specified by the provided {SMSMessageSid}.

Example

HTTP POST

Not supported.

HTTP PUT

Not supported.

HTTP DELETE

Not supported.

SMS Messages List Resource

Resource URI

/2010-04-01/Accounts/{AccountSid}/SMS/Messages

HTTP GET

Returns a list of SMS messages associated with your account. The list includes paging information.

List Filters

You may limit the list by providing certain query string parameters to the listing resource. Note, parameters are case-sensitive:

Parameter Description
To Only show SMS messages to this phone number.
From Only show SMS messages from this phone number.
DateSent Only show SMS messages sent on this date (in GMT format), given as YYYY-MM-DD. Example: DateSent=2009-07-06. You can also specify inequality, such as DateSent<=YYYY-MM-DD for SMS messages that were sent on or before midnight on a date, and DateSent>=YYYY-MM-DD for SMS messages sent on or after midnight on a date.
Example

Grab the whole list of messages.

HTTP POST

Sends a new SMS message. For details see the Sending SMS section.

HTTP PUT

Not supported.

HTTP DELETE

Not supported.