Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Alternative Representations



Vanity URLs

vanity-urls page anchor
(warning)

Warning

Effective November 1, 2024, CNAME for unauthenticated access to HTTP Voice recording media URLs will no longer be supported. For more information, see the Changelog(link takes you to an external page).

You can create a CNAME of our API URLs and serve up recording media from a hostname of your choosing! To do this, create a CNAME record with your DNS provider that points to api.twilio.com.


Alternate Representations

alternate-representations page anchor

Twilio's 2010 APIs (those under api.twilio.com/2010-04-01/Accounts) respond as XML by default, but can also return JSON, CSV, and even HTML. (Note: Newer APIs of the form productname.twilio.com/v1 are only available as JSON responses.)

CSV

alternate-representations-csv page anchor

Append a .csv to the end of REST URLs, and you'll get a Comma Separated Values (CSV)(link takes you to an external page) representation of the data, with a header row describing the columns. For example, if you requested the following Calls resource, the default representation is XML:

GET /2010-04-01/Accounts/AC30947.../Calls


_39
<TwilioResponse>
_39
<Calls page="0" numpages="1" pagesize="50" total="38" start="0" end="37">
_39
<Call>
_39
<Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
_39
<DateCreated>Sat, 07 Feb 2009 13:15:19 +0000</DateCreated>
_39
<DateUpdated>Sat, 07 Feb 2009 13:15:19 +0000</DateUpdated>
_39
<AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
_39
<To>+14159633717</To>
_39
<From>+14156767925</From>
_39
<PhoneNumberSid>PN012345678901246789012345678900</PhoneNumberSid>
_39
<Status>completed</Status>
_39
<StartTime>Thu, 03 Apr 2008 04:36:33 +0000</StartTime>
_39
<EndTime>Thu, 03 Apr 2008 04:36:47 +0000</EndTime>
_39
<Duration>14</Duration>
_39
<Price/>
_39
<Flags>
_39
<Flag>inbound</Flag>
_39
</Flags>
_39
</Call>
_39
<Call>
_39
<Sid>CA751e8fa0a0105cf26a0d7a9775fb4bfb</Sid>
_39
<DateCreated>Sat, 07 Feb 2009 13:15:19 +0000</DateCreated>
_39
<DateUpdated>Sat, 07 Feb 2009 13:15:19 +0000</DateUpdated>
_39
<AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
_39
<To>+12064287985</To>
_39
<From>+14156767925</From>
_39
<PhoneNumberSid>PNd59c2ba27ef482647db90476d1674</PhoneNumberSid>
_39
<Status>completed</Status>
_39
<StartTime>Thu, 03 Apr 2008 01:37:05 +0000</StartTime>
_39
<EndTime>Thu, 03 Apr 2008 01:37:40 +0000</EndTime>
_39
<Duration>35</Duration>
_39
<Price/>
_39
<Flags>
_39
<Flag>inbound</Flag>
_39
</Flags>
_39
</Call>
_39
...
_39
</Calls>
_39
</TwilioResponse>

Appending a .csv, you'd get a CSV representation of the same data with mime-type 'text/csv'. Each Call is a row in the table, and each XML element is a column:

GET /2010-04-01/Accounts/AC30947.../Calls.csv

Would return:


_10
Sid, DateCreated, DateUpdated, AccountSid, To, From, ...
_10
CA42ed11f93dc08b952027ffbc406d0868,"Sat, 07 Feb 2009 13:15:19 +0000",
_10
"Sat, 07 Feb 2009 13:15:19 +0000",AC309475e5fede1b49e100272a8640f438,
_10
+14159633717,+14156767925,PN01234567890123456789012345678900,"completed","Thu,
_10
03 Apr 2008 04:36:33 +0000","Thu, 03 Apr 2008 04:36:47 +0000",14,,inbound,,

NOTE: The order of the columns in the CSV is not defined and may change when new fields are added to the API response. Your application design should be resilient to changes in the order of the columns in the CSV response.

You can also request JSON responses by appending a .json to the end of any REST URL. The response mime-type is 'application/json'.

The 2010-04-01 API version returns a new format for JSON responses than previous REST API versions. This format includes paging information and a simplified structure for resources!

For example, to retrieve IncomingPhoneNumber records as JSON:

GET /2010-04-01/Accounts/AC33d49.../IncomingPhoneNumbers.json


_40
{
_40
"incoming_phone_numbers":[
_40
{
_40
"sid":"PNd6b0e1e84f7b117332aed2fd2e5bbcab",
_40
"account_sid":"AC228ba7a5fe4238be081ea6f3c44186f3",
_40
"friendly_name":"My Phone Number",
_40
"phone_number":"+15104444444",
_40
"voice_url":"",
_40
"voice_method":"POST",
_40
"voice_fallback_url":"",
_40
"voice_fallback_method":"POST",
_40
"voice_caller_id_lookup":false,
_40
"date_created":"Thu, 29 Jul 2010 21:00:17 +0000","
_40
date_updated":"Mon, 09 Aug 2010 22:14:20 +0000",
_40
"sms_url":"http:\/\/www.google.com",
_40
"sms_method":"POST",
_40
"sms_fallback_url":"",
_40
"sms_fallback_method":"POST",
_40
"capabilities": {
_40
"voice":true,
_40
"sms":true
_40
},
_40
"status_callback":null,
_40
"status_callback_method":null,
_40
"api_version":"2008-08-01",
_40
"uri":"\/2010-04-01\/Accounts\/AC228ba7a5fe4238be081ea6f3c44186f3\/IncomingPhoneNumbers\/PNd6b0e1e84f7b117332aed2fd2e5bbcab.json"
_40
}
_40
],
_40
"page":0,
_40
"num_pages":1,
_40
"page_size":50,
_40
"total":2,
_40
"start":0,
_40
"end":1,
_40
"uri":"\/2010-04-01\/Accounts\/AC228ba7a5fe4238be081ea6f3c44186f3\/IncomingPhoneNumbers.json",
_40
"first_page_uri":"\/2010-04-01\/Accounts\/AC228ba7a5fe4238be081ea6f3c44186f3\/IncomingPhoneNumbers.json?Page=0&PageSize=50",
_40
"previous_page_uri":null,
_40
"next_page_uri":null,
_40
"last_page_uri":"\/2010-04-01\/Accounts\/AC228ba7a5fe4238be081ea6f3c44186f3\/IncomingPhoneNumbers.json?Page=0&PageSize=50"
_40
}

You can also get Twilio to return the same objects formatted as HTML by appending a .html to the end of any URL. This may be useful if you intend to pass this data directly to a browser, but will require you to complete the URIs with the correct subdomain (generally api.twilio.com).

For example, consider the following XML representation of an account:

GET /2010-04-01/Accounts/AC35542fc30a091bed0c1ed511e1d9935d


_16
<TwilioResponse>
_16
<Account>
_16
<Sid>AC228ba7a5fe4238be081ea6f3c44186f3</Sid>
_16
<FriendlyName>folly@folly.com's Account</FriendlyName>
_16
<Status>Active</Status>
_16
<DateCreated>Tue, 27 Jul 2010 01:54:11 +0000</DateCreated>
_16
<DateUpdated>Thu, 29 Jul 2010 20:59:01 +0000</DateUpdated>
_16
<AuthToken>f9dd7f4177babe34369f719e1d76c0df</AuthToken>
_16
<Uri>/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3</Uri>
_16
<SubresourceUris>
_16
<AvailablePhoneNumbers>/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/AvailablePhoneNumbers.xml</AvailablePhoneNumbers>
_16
<Calls>/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/Calls.xml</Calls>
_16
...
_16
</SubresourceUris>
_16
</Account>
_16
</TwilioResponse>

The same resource, represented as HTML is shown below. Note the .html appended to the URI:

GET /2010-04-01/Accounts/AC35542fc30a091bed0c1ed511e1d9935d.html


_34
<html>
_34
<head><title>200</title></head>
_34
<body class="twilio-response">
_34
<div class="account">
_34
<h1>Account</h1>
_34
<dl>
_34
<dt>sid</dt>
_34
<dd>AC228ba7a5fe4238be081ea6f3c44186f3</dd>
_34
<dt>friendly-name</dt>
_34
<dd>folly@folly.com's Account</dd>
_34
<dt>status</dt>
_34
<dd>Active</dd>
_34
<dt>date-created</dt>
_34
<dd>Tue, 27 Jul 2010 01:54:11 +0000</dd>
_34
<dt>date-updated</dt>
_34
<dd>Thu, 29 Jul 2010 20:59:01 +0000</dd>
_34
<dt>auth-token</dt>
_34
<dd>f9dd7f4177babe34369f719e1d76c0df</dd>
_34
<dt>uri</dt>
_34
<dd><a href="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3.html">/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3.html</a></dd>
_34
<dt>subresource-uris</dt>
_34
<dd>
_34
<dl class="subresource-uris">
_34
<dt>available-phone-numbers</dt>
_34
<dd><a href="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/AvailablePhoneNumbers.html">/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/AvailablePhoneNumbers.html</a></dd>
_34
<dt>calls</dt>
_34
<dd><a href="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/Calls.html">/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/Calls.html</a></dd>
_34
<dt>conferences</dt>
_34
...
_34
</dl></dd>
_34
</dl>
_34
</div>
_34
</body>
_34
</html>


Rate this page: