List

View as Markdown

Use this endpoint for the Media method to return a paged list of messages sorted with the most recent messages appearing first.

Path parameters

AccountSidstringRequiredformat: "uuid"
The unique identifier of the project that sent or received this message.

Query parameters

DateSentstringOptional
Only return messages sent on this particular date, formatted as YYYY-MM-DD in UTC.
DateSent<stringOptional
Only return messages sent before this date, formatted as YYYY-MM-DD in UTC.
DateSent>stringOptional
Only return messages sent after this date, formatted as YYYY-MM-DD in UTC.
FromstringOptional
The phone number in E.164 format. For inbound messages, this will be the remote phone number who sent the message. For outbound messages, this will be one of your SignalWire phone numbers.
TostringOptional
The phone number in E.164 format that received the message. For inbound messages, this is one of your SignalWire phone numbers; for outbound messages, this is the remote phone number that received the message.
StatusenumOptional
Current status of the message.
PageintegerOptional>=0Defaults to 0
The page number to retrieve. Default is 0.
PageSizeintegerOptional1-1000Defaults to 50
The number of items per page. Default is 50, maximum is 1000.
PageTokenstringOptional
The token for cursor-based pagination. Must start with 'PA' or 'PB'.

Response

uristringRequired
The URI of the current page.
first_page_uristringRequired
The URI of the first page.
next_page_uristring or nullRequired
The URI of the next page, or null if there are no more pages.
previous_page_uristring or nullRequired
The URI of the previous page, or null if this is the first page.
pageintegerRequired
The current page number.
page_sizeintegerRequired
The number of items per page.
messageslist of objectsRequired
List of messages.
Response
1{
2 "uri": "/api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages?Page=0&PageSize=50",
3 "first_page_uri": "/api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages?Page=0&PageSize=50",
4 "next_page_uri": "/api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages?Page=1&PageSize=50&PageToken=PA0a059168ead041af",
5 "previous_page_uri": "string",
6 "page": 0,
7 "page_size": 50,
8 "messages": [
9 {
10 "account_sid": "ea108133-d6b3-407c-9536-9fad8a929a6a",
11 "api_version": "2010-04-01",
12 "body": "Hello World!",
13 "num_segments": 1,
14 "num_media": 1,
15 "date_created": "Mon, 13 Aug 2018 21:38:46 +0000",
16 "date_sent": "Mon, 13 Aug 2018 21:38:46 +0000",
17 "date_updated": "Mon, 13 Aug 2018 21:38:46 +0000",
18 "direction": "inbound",
19 "error_code": "30001",
20 "error_message": "Queue overflow",
21 "from": "+15551234567",
22 "price": 0.005,
23 "price_unit": "USD",
24 "sid": "0a059168-ead0-41af-9d1f-343dae832527",
25 "status": "queued",
26 "to": "+15557654321",
27 "messaging_service_sid": "b3877c40-da60-4998-90ad-b792e98472ms",
28 "uri": "/api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages/0a059168-ead0-41af-9d1f-343dae832527.json",
29 "subresource_uris": {
30 "media": "/api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages/0a059168-ead0-41af-9d1f-343dae832527/Media.json"
31 }
32 }
33 ]
34}

Request examples

1const { RestClient } = require('@signalwire/compatibility-api')
2const client = RestClient('YourProjectID', 'YourAuthToken', { signalwireSpaceUrl: 'example.signalwire.com' })
3
4client.messages.each(messages => console.log(messages.sid));

Request: filter by date and from

In this example, we will filter messages to return only those sent from +15551234567 on or after 2018-08-01.

1const { RestClient } = require('@signalwire/compatibility-api')
2const client = RestClient('YourProjectID', 'YourAuthToken', { signalwireSpaceUrl: 'example.signalwire.com' })
3
4client.messages.each({ dateSent: new Date(Date.UTC(2018, 8, 1, 0, 0, 0)), from: '+15551234567' },
5 messages => console.log(messages.sid)
6 );