REST API: SMS Messages

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, 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, or failed.
Direction The direction of this SMS message. incoming 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.
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

HTTP GET

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

Example
Try it now
  • GET /2010-04-01/Accounts/AC5ef87.../SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec

    <TwilioResponse>
        <SMSMessage>
            <Sid>SM800f449d0399ed014aae2bcc0cc2f2ec</Sid>
            <DateCreated>Mon, 16 Aug 2010 03:45:01 +0000</DateCreated>
            <DateUpdated>Mon, 16 Aug 2010 03:45:03 +0000</DateUpdated>
            <DateSent>Mon, 16 Aug 2010 03:45:03 +0000</DateSent>
            <AccountSid>AC5ef872f6da5a21de157d80997a64bd33</AccountSid>
            <To>+14159978453</To>
            <From>+14158141829</From>
            <Body>Hey Jenny why aren't you returning my calls?</Body>
            <Status>sent</Status>
            <Direction>outbound-api</Direction>
            <ApiVersion>2010-04-01</ApiVersion>
            <Price>-0.02000</Price>
            <Uri>/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec</Uri>
        </SMSMessage>
    </TwilioResponse>    

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 and is sorted by DateSent, with most recent messages first.

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

Try it now
  • GET /2010-04-01/Accounts/AC5ef87.../SMS/Messages

    <TwilioResponse>
        <SMSMessages page="0" numpages="6" pagesize="50" total="261" start="0" end="49" uri="/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages" firstpageuri="/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages?Page=0&amp;PageSize=50" previouspageuri="" nextpageuri="/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages?Page=1&amp;PageSize=50" lastpageuri="/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages?Page=5&amp;PageSize=50">
            <SMSMessage>
                <Sid>SM800f449d0399ed014aae2bcc0cc2f2ec</Sid>
                <DateCreated>Mon, 16 Aug 2010 03:45:01 +0000</DateCreated>
                <DateUpdated>Mon, 16 Aug 2010 03:45:03 +0000</DateUpdated>
                <DateSent>Mon, 16 Aug 2010 03:45:03 +0000</DateSent>
                <AccountSid>AC5ef872f6da5a21de157d80997a64bd33</AccountSid>
                <To>+14159978453</To>
                <From>+14158141829</From>
                <Body>Hey Jenny why aren't you returning my calls?</Body>
                <Status>sent</Status>
                <Direction>outbound-api</Direction>
                <Price>-0.02000</Price>
                <ApiVersion>2008-08-01</ApiVersion>
                <Uri>/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec</Uri>
            </SMSMessage>
            ...
        </SMSMessages>
    </TwilioResponse>    

HTTP POST

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

HTTP PUT

Not supported.

HTTP DELETE

Not supported.