Getting started

The Twilio REST API allows you to query related properties about your account, phone numbers, calls, text messages, and recordings. You can also initiate outbound calls and send text messages.

API Base URL

The Twilio REST API is served over HTTPS to ensure data privacy. Therefore, HTTP is not supported. Below is the Base URL for the Twilio REST API:

https://api.twilio.com/2010-04-01

🚧

INFO

Certain resources cannot be accessed via the BASE URL. For example, the AuthToken resource is accessed via the accounts.twilio.com subdomain.

API version

Twilio REST API currently uses the 2010-04-01 version. This is an upgrade from the previous v2008 version. Check out the Twilio REST API migration guide for the features and capabilities of the new version.

Response format

The Twilio API allows you to get API response in different formats. The most common are XML and JSON object. By default, Twilio's REST API returns XML. For example, a request to /Accounts endpoint will return an XML response. However, to get a JSON response, you need to add .json to the URL. For example, a request to /Accounts.json endpoint will return a JSON response. Learn more here.

Rate-limiting

Read the Twilio best practices guide for rate-limiting information.

API errors

When an error is triggered, Twilio REST API returns a JSON response with the following fields:

  1. A code field, e.g. 20404
  2. A message which contains details about the error trigger.
  3. A more_info field which is a link to the error description, causes, and possible solutions.
  4. A status_code field which is a standard REST API status code, e.g. 404, 400.

Below is a sample error response from the Secondary AuthToken resource:

{
  "code": 20404,
  "message": "The requested resource /AuthTokens/Promote was not found",
  "more_info": "https://www.twilio.com/docs/errors/20404",
  "status": 404
}

See the full list of error codes in the errors and warning dictionary

Encoding-type

The body parameters must be encoded using the application/x-www-form-urlencoded encoding type. This means that the request headers must use this encoding-type for the content-type field. Here is an example below:

content-type: application/x-www-form-urlencoded