Retrieve a list of Message resources associated with a Twilio Account

GET /2010-04-01/Accounts/{AccountSid}/Messages.json

A Message resource represents an inbound or outbound message.

Retrieve a list of Message resources associated with a Twilio Account

Path parameters

  • AccountSid string Required

    The SID of the Account associated with the Message resources.

    Minimum length is 34, maximum length is 34. Format should match the following pattern: ^AC[0-9a-fA-F]{32}$.

Query parameters

  • To string(phone-number)

    Filter by recipient. For example: Set this to parameter to +15558881111 to retrieve a list of Message resources with to properties of +15558881111

  • From string(phone-number)

    Filter by sender. For example: Set this from parameter to +15552229999 to retrieve a list of Message resources with from properties of +15552229999

  • DateSent string(date-time)

    Filter by Message sent_date. Accepts GMT dates in the following formats: YYYY-MM-DD (to find Messages with a specific sent_date), <=YYYY-MM-DD (to find Messages with sent_dates on and before a specific date), and >=YYYY-MM-DD (to find Messages with sent_dates on and after a specific date).

  • DateSent< string(date-time)

    Filter by Message sent_date. Accepts GMT dates in the following formats: YYYY-MM-DD (to find Messages with a specific sent_date), <=YYYY-MM-DD (to find Messages with sent_dates on and before a specific date), and >=YYYY-MM-DD (to find Messages with sent_dates on and after a specific date).

  • DateSent> string(date-time)

    Filter by Message sent_date. Accepts GMT dates in the following formats: YYYY-MM-DD (to find Messages with a specific sent_date), <=YYYY-MM-DD (to find Messages with sent_dates on and before a specific date), and >=YYYY-MM-DD (to find Messages with sent_dates on and after a specific date).

  • PageSize integer(int64)

    How many resources to return in each list page. The default is 50, and the maximum is 1000.

    Minimum value is 1, maximum value is 1000.

  • Page integer

    The page index. This value is simply for client state.

    Minimum value is 0.

  • PageToken string

    The page token. This is provided by the API.

Responses

  • 200 application/json

    OK

    Hide headers attributes Show headers attributes
    • Access-Control-Allow-Origin string

      Specify the origin(s) allowed to access the resource

    • Access-Control-Allow-Methods string

      Specify the HTTP methods allowed when accessing the resource

    • Access-Control-Allow-Headers string

      Specify the headers allowed when accessing the resource

    • Access-Control-Allow-Credentials boolean

      Indicates whether the browser should include credentials

    • Access-Control-Expose-Headers string

      Headers exposed to the client

    Hide response attributes Show response attributes object
    • messages array[object]
      Hide messages attributes Show messages attributes object
      • body string | null

        The text content of the message

      • num_segments string | null

        The number of segments that make up the complete message. SMS message bodies that exceed the character limit are segmented and charged as multiple messages. Note: For messages sent via a Messaging Service, num_segments is initially 0, since a sender hasn't yet been assigned.

      • direction string

        The direction of the message. Can be: inbound for incoming messages, outbound-api for messages created by the REST API, outbound-call for messages created during a call, or outbound-reply for messages created in response to an incoming message.

        Values are inbound, outbound-api, outbound-call, or outbound-reply.

      • from string(phone-number) | null

        The sender's phone number (in E.164 format), alphanumeric sender ID, Wireless SIM, short code, or channel address (e.g., whatsapp:+15554449999). For incoming messages, this is the number or channel address of the sender. For outgoing messages, this value is a Twilio phone number, alphanumeric sender ID, short code, or channel address from which the message is sent.

      • to string | null

        The recipient's phone number (in E.164 format) or channel address (e.g. whatsapp:+15552229999)

      • date_updated string(date-time-rfc-2822) | null

        The RFC 2822 timestamp (in GMT) of when the Message resource was last updated

      • price string | null

        The amount billed for the message in the currency specified by price_unit. The price is populated after the message has been sent/received, and may not be immediately availalble. View the Pricing page for more details.

      • error_message string | null

        The description of the error_code if the Message status is failed or undelivered. If no error was encountered, the value is null. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the error_code and error_message fields programmatically.

      • uri string | null

        The URI of the Message resource, relative to https://api.twilio.com.

      • account_sid string | null

        The SID of the Account associated with the Message resource

        Minimum length is 34, maximum length is 34. Format should match the following pattern: ^AC[0-9a-fA-F]{32}$.

      • num_media string | null

        The number of media files associated with the Message resource.

      • status string

        The status of the Message. Possible values: accepted, scheduled, canceled, queued, sending, sent, failed, delivered, undelivered, receiving, received, or read (WhatsApp only). For more information, See detailed descriptions.

        Values are queued, sending, sent, failed, delivered, undelivered, receiving, received, accepted, scheduled, read, partially_delivered, or canceled.

      • messaging_service_sid string | null

        The SID of the Messaging Service associated with the Message resource. A unique default value is assigned if a Messaging Service is not used.

        Minimum length is 34, maximum length is 34. Format should match the following pattern: ^MG[0-9a-fA-F]{32}$.

      • sid string | null

        The unique, Twilio-provided string that identifies the Message resource.

        Minimum length is 34, maximum length is 34. Format should match the following pattern: ^(SM|MM)[0-9a-fA-F]{32}$.

      • date_sent string(date-time-rfc-2822) | null

        The RFC 2822 timestamp (in GMT) of when the Message was sent. For an outgoing message, this is when Twilio sent the message. For an incoming message, this is when Twilio sent the HTTP request to your incoming message webhook URL.

      • date_created string(date-time-rfc-2822) | null

        The RFC 2822 timestamp (in GMT) of when the Message resource was created

      • error_code integer | null

        The error code returned if the Message status is failed or undelivered. If no error was encountered, the value is null. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the error_code and error_message fields programmatically.

      • price_unit string(currency) | null

        The currency in which price is measured, in ISO 4127 format (e.g. usd, eur, jpy).

      • api_version string | null

        The API version used to process the Message

      • subresource_uris object(uri-map) | null

        A list of related resources identified by their URIs relative to https://api.twilio.com

    • end integer
    • first_page_uri string(uri)
    • next_page_uri string(uri) | null
    • page integer
    • page_size integer
    • previous_page_uri string(uri) | null
    • start integer
    • uri string(uri)
GET /2010-04-01/Accounts/{AccountSid}/Messages.json
curl \
 --request GET 'https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json' \
 --user "username:password"
{
  "end": 1,
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2008-01-02&PageSize=2&Page=0",
  "page": 0,
  "start": 0,
  "messages": [
    {
      "to": "+18182008801",
      "sid": "SMded05904ccb347238880ca9264e8fe1c",
      "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMded05904ccb347238880ca9264e8fe1c.json",
      "body": "testing",
      "from": "+12019235161",
      "tags": {
        "message_type": "cart_abandoned",
        "campaign_name": "Spring Sale 2022"
      },
      "price": "-0.00750",
      "status": "sent",
      "date_sent": "Fri, 24 May 2019 17:44:50 +0000",
      "direction": "outbound-api",
      "num_media": "0",
      "error_code": null,
      "price_unit": "USD",
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "api_version": "2010-04-01",
      "date_created": "Fri, 24 May 2019 17:44:46 +0000",
      "date_updated": "Fri, 24 May 2019 17:44:50 +0000",
      "num_segments": "1",
      "error_message": null,
      "subresource_uris": {
        "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMded05904ccb347238880ca9264e8fe1c/Media.json",
        "feedback": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMded05904ccb347238880ca9264e8fe1c/Feedback.json"
      },
      "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    },
    {
      "to": "+18182008801",
      "sid": "MMc26223853f8c46b4ab7dfaa6abba0a26",
      "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMc26223853f8c46b4ab7dfaa6abba0a26.json",
      "body": "look mom I have media!",
      "from": "+12019235161",
      "tags": {
        "message_type": "cart_abandoned",
        "campaign_name": "Spring Sale 2022"
      },
      "price": "-0.00750",
      "status": "received",
      "date_sent": "Fri, 24 May 2019 17:44:49 +0000",
      "direction": "inbound",
      "num_media": "3",
      "error_code": 30004,
      "price_unit": "USD",
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "api_version": "2010-04-01",
      "date_created": "Fri, 24 May 2019 17:44:46 +0000",
      "date_updated": "Fri, 24 May 2019 17:44:49 +0000",
      "num_segments": "1",
      "error_message": "Message blocked",
      "subresource_uris": {
        "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMc26223853f8c46b4ab7dfaa6abba0a26/Media.json",
        "feedback": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMc26223853f8c46b4ab7dfaa6abba0a26/Feedback.json"
      },
      "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  ],
  "page_size": 2,
  "next_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2008-01-02&PageSize=2&Page=1&PageToken=PAMMc26223853f8c46b4ab7dfaa6abba0a26",
  "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2008-01-02&PageSize=2&Page=0",
  "previous_page_uri": null
}
{
  "end": 0,
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3C=2008-01-02&PageSize=25&Page=0",
  "page": 0,
  "start": 0,
  "messages": [],
  "page_size": 25,
  "next_page_uri": null,
  "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3C=2008-01-02&PageSize=25&Page=0",
  "previous_page_uri": null
}
{
  "end": 0,
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent=2008-01-02&PageSize=25&Page=0",
  "page": 0,
  "start": 0,
  "messages": [],
  "page_size": 25,
  "next_page_uri": null,
  "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent=2008-01-02&PageSize=25&Page=0",
  "previous_page_uri": null
}
{
  "end": 0,
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2008-01-02&PageSize=25&Page=0",
  "page": 0,
  "start": 0,
  "messages": [],
  "page_size": 25,
  "next_page_uri": null,
  "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2008-01-02&PageSize=25&Page=0",
  "previous_page_uri": null
}
{
  "end": 0,
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=06%2F11%2F2019+22%3A05%3A25+MST&PageSize=25&Page=0",
  "page": 0,
  "start": 0,
  "messages": [],
  "page_size": 25,
  "next_page_uri": null,
  "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=06%2F11%2F2019+22%3A05%3A25+MST&PageSize=25&Page=0",
  "previous_page_uri": null
}
{
  "end": 0,
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2019-06-11+22%3A05%3A25.000&PageSize=25&Page=0",
  "page": 0,
  "start": 0,
  "messages": [],
  "page_size": 25,
  "next_page_uri": null,
  "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=2019-06-11+22%3A05%3A25.000&PageSize=25&Page=0",
  "previous_page_uri": null
}
{
  "end": 0,
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=Wed%2C+19+Jun+2019+22%3A04%3A00+-0000&PageSize=25&Page=0",
  "page": 0,
  "start": 0,
  "messages": [],
  "page_size": 25,
  "next_page_uri": null,
  "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?To=%2B123456789&From=%2B987654321&DateSent%3E=Wed%2C+19+Jun+2019+22%3A04%3A00+-0000&PageSize=25&Page=0",
  "previous_page_uri": null
}