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

Preview

Preview is a version that allows access to test experimental features that are not yet released.

The preview API is available at https://comms.twilio.com/preview.
Preview is continuously updated and may be unstable; it is NOT for production use.

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 body with fields operationId.
  • This field contains a unique identifier for the Operation that represents the async job.
  • You can use the operationId and operationLocation values 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 operationId & operationLocation field from the 202 response body can be used to track the progress of the async job.

1

Send Messages Request

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

POST
/v1/Messages
1import { TwilioClient } from "twilio-comms";
2
3async function main() {
4 const client = new TwilioClient({
5 accountId: "YOUR_ACCOUNTID_HERE",
6 authToken: "YOUR_AUTHTOKEN_HERE",
7 });
8 await client.messages.send({
9 to: [
10 {
11 address: "+14153902337",
12 channel: "PHONE",
13 },
14 ],
15 content: {
16 text: "Hello, World!",
17 },
18 });
19}
20main();

receiving HTTP 202 (Accepted) response:

Response FieldExample Value
operationIdcomms_operation_01k4vge2fxe3ramtcdv1zx1s9s
operationLocation/Messages/Operations/comms_operation_01k4vge2fxe3ramtcdv1zx1s9s
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

When the Operation is completed, retrieve the created Message resources by issuing:

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

and process the paginated response to read 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 "createdAt": "2025-09-11T04:27:12Z",
15 "updatedAt": "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 Email 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 pageToken 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?pageSize=50&pageToken=okCy7mKb-s4x3QOwnQPHmIQuEiinaoXy4OTUXF0msnPlH52cXmByhGnECL_ClHkCQiuVJ4oXDTuNiHllao4"
8 }
9}

The pagination query parameters are:

pageToken
string

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

pageSize
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?pageToken=1P_oxvlUFrvT0HSwOIjkxxW5hW9d9ynzrDWM5UHbTWkP7EBqWF2aYcu1CqHxjqC2IeSPdYD3cSjuo6qbrdM&pageSize=50

The number of items to retrieve can be controlled with the pageSize 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.