API Mechanics

API Versions

The Communications API is versioned.

The version is specified in the URL path, immediately after the hostname. Thus, all API endpoints are versioned together.

For example, in the URL https://comms.twilio.com/v1/Messages, the version is v1.

Mainline Versions (v1, v2, etc.)

Communications API versions are released periodically with monotonically increasing integers with โ€˜vโ€™ prefix, e.g. v1.

Latest Version: v1

https://comms.twilio.com/v1. Try It Now

For previous versions, see the API Changelog.

Operations & HTTP 202 Responses

The Communications API exposes several โ€˜factoryโ€™ API endpoints that create and start asynchronous jobs.

These API endpoints return an HTTP 202 (Accepted) success response which indicates that the workload has been accepted for processing.

  • To track the progress of your workload, the API provides an HTTP response header operation-id.
  • This header contains a unique identifier for the Operation that represents the async job.
  • You can use the operation-id and operation-location headers to query the status of your job by fetching the corresponding Operation resource.
  • Once the job is complete, the Operation will have status completed.
The 202 status code means your request is valid and has been queued for processing.

The resource-location header from the 202 response points to where the resultant resources of the โ€˜factoryโ€™ endpoint can be retrieved.

1

Send Messages Request

When using the Send Messages API (a factory operation), the API user issues a request:

POST
/v1/Messages
1curl -X POST 'https://comms.twilio.com/preview/Messages' \
2--header 'Content-Type: application/json' \
3--data '{
4 "to": [{
5 "address": "+12065551337",
6 "channel": "phone"
7 }],
8 "content": {
9 "text": "What day is it?"
10 }
11}'\
12-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN \

receiving HTTP 202 (Accepted) response with these headers:

HTTP HeaderExample Value
operation-idcomms_operation_01k4vge2fxe3ramtcdv1zx1s9s
operation-location/v1/Messages/Operations/comms_operation_01k4vge2fxe3ramtcdv1zx1s9s
resource-location/v1/Messages
2

Fetch Operation Request

Next, the user can get the status of the Operation by fetching it โ€” issuing:

1GET https://comms.twilio.com/v1/Messages/Operations/comms_operation_01k4vge2fxe3ramtcdv1zx1s9s

receiving HTTP 200 (OK) with:

3

List Messages Request

Next, to retrieve the created Message resources, the API user can issue:

1GET https://comms.twilio.com/v1/Messages?operation_id=comms_operation_01k4vge2fxe3ramtcdv1zx1s9s

and process the response to continue to page through all Messages created by the Operation.

The Communications API provides a field on many API resources with the name related. This field contains an array of related resources, making it easier to navigate to associated data and understand relationships.

For example, when retrieving a Message resource, t he response contains a related field with the associated Session resource:

1{
2 "id": "comms_message_01k4vge32ce3ar18sy56svjjpb",
3 "status": "delivered",
4 "content": {
5 "text": "Ahoy, world!"
6 },
7 ...
8 "{{related}}": [
9 {
10 "id": "comms_session_96c975d029164690a4abcc47afcf4938",
11 "name": "session"
12 }
13 ],
14 "created_at": "2025-09-11T04:27:12Z",
15 "updated_at": "2025-09-11T04:27:53Z"
16}

Tags

Many resources in the Communications API have a tags field. This field contains up to 10 simple key-value pairs that the API user may write and read to associate custom metadata with their API resources.

For example, here is an Audience with tags:

Events & Webhooks

To handle asynchronous events, Twilio provides Event Streams API.

Event Streams API provides access to a unified stream of every interaction sent or received on Twilio.

Event Streams supports streaming events to multiple sinks (destinations) and different types of delivery mechanisms, including:

To see a list of all events generated by the Communications API, visit Communications API Events.

Pagination

The Communications API uses cursor-based pagination for list endpoints.

When listing resources, the response includes a pagination field with the pagination information.

The pagination fields in a list Response are:

Pagination FieldDescription
nextToken to supply to the page_token query parameter
selfURI that points to the current page (token inserted)

For example, when fetching a page of Messages, the response will contain:

1{
2 "messages": [
3 ...
4 ],
5 "pagination": {
6 "next": "1P_oxvlUFrvT0HSwOIjkxxW5hW9d9ynzrDWM5UHbTWkP7EBqWF2aYcu1CqHxjqC2IeSPdYD3cSjuo6qbrdM",
7 "self": "/Messages?page_size=50&page_token=okCy7mKb-s4x3QOwnQPHmIQuEiinaoXy4OTUXF0msnPlH52cXmByhGnECL_ClHkCQiuVJ4oXDTuNiHllao4"
8 }
9}

The pagination query parameters are:

page_token
string

Supply with a valid page token (acquired from previous request) to set your cursor.

page_size
string

Number of resources to retrieve [1-1000], default: 50

To retrieve the โ€˜nextโ€™ page of Messages get the value in the response body pagination.next field and issue:

1GET https://comms.twilio.com/v1/Messages?page_token=1P_oxvlUFrvT0HSwOIjkxxW5hW9d9ynzrDWM5UHbTWkP7EBqWF2aYcu1CqHxjqC2IeSPdYD3cSjuo6qbrdM&page_size=50

The number of items to retrieve can be controlled with the page_size query parameter.

Errors

The Communications API uses standard HTTP status codes to indicate the success or failure of an API request.

Error HTTP Responses (400s and 500s)

When the Communications API returns an error (HTTP status code 4xx or 5xx), the response body contains the following field:

FieldTypeDescription
errorsarrayAn array of error objects

Each element of the errors array has the following fields:

FieldTypeDescription
codeintegerThe Twilio error code that can be looked up via the Twilio Errors Page
messagestringA descriptive message about the error that occurred

For example when supplying an invalid value to the query parameter channel when listing Messages:

1{
2 "errors": [
3 {
4 "code": 400,
5 "message": "The value 'phonee' is not recognized for the field 'channel'."
6 }
7 ],
8 "status": 400
9}

Console & Debugging

Visit the Twilio Console to configure your account, review error logs, view insights, and more.

Support

Visit the Twilio Help Center for documentation, FAQs, and to contact support.