Skip to contentSkip to navigationSkip to topbar
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

1
<TwilioResponse>
2
<Calls page="0" numpages="1" pagesize="50" total="38" start="0" end="37">
3
<Call>
4
<Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
5
<DateCreated>Sat, 07 Feb 2009 13:15:19 +0000</DateCreated>
6
<DateUpdated>Sat, 07 Feb 2009 13:15:19 +0000</DateUpdated>
7
<AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
8
<To>+14159633717</To>
9
<From>+14156767925</From>
10
<PhoneNumberSid>PN012345678901246789012345678900</PhoneNumberSid>
11
<Status>completed</Status>
12
<StartTime>Thu, 03 Apr 2008 04:36:33 +0000</StartTime>
13
<EndTime>Thu, 03 Apr 2008 04:36:47 +0000</EndTime>
14
<Duration>14</Duration>
15
<Price/>
16
<Flags>
17
<Flag>inbound</Flag>
18
</Flags>
19
</Call>
20
<Call>
21
<Sid>CA751e8fa0a0105cf26a0d7a9775fb4bfb</Sid>
22
<DateCreated>Sat, 07 Feb 2009 13:15:19 +0000</DateCreated>
23
<DateUpdated>Sat, 07 Feb 2009 13:15:19 +0000</DateUpdated>
24
<AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
25
<To>+12064287985</To>
26
<From>+14156767925</From>
27
<PhoneNumberSid>PNd59c2ba27ef482647db90476d1674</PhoneNumberSid>
28
<Status>completed</Status>
29
<StartTime>Thu, 03 Apr 2008 01:37:05 +0000</StartTime>
30
<EndTime>Thu, 03 Apr 2008 01:37:40 +0000</EndTime>
31
<Duration>35</Duration>
32
<Price/>
33
<Flags>
34
<Flag>inbound</Flag>
35
</Flags>
36
</Call>
37
...
38
</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:

1
Sid, DateCreated, DateUpdated, AccountSid, To, From, ...
2
CA42ed11f93dc08b952027ffbc406d0868,"Sat, 07 Feb 2009 13:15:19 +0000",
3
"Sat, 07 Feb 2009 13:15:19 +0000",AC309475e5fede1b49e100272a8640f438,
4
+14159633717,+14156767925,PN01234567890123456789012345678900,"completed","Thu,
5
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

1
{
2
"incoming_phone_numbers":[
3
{
4
"sid":"PNd6b0e1e84f7b117332aed2fd2e5bbcab",
5
"account_sid":"AC228ba7a5fe4238be081ea6f3c44186f3",
6
"friendly_name":"My Phone Number",
7
"phone_number":"+15104444444",
8
"voice_url":"",
9
"voice_method":"POST",
10
"voice_fallback_url":"",
11
"voice_fallback_method":"POST",
12
"voice_caller_id_lookup":false,
13
"date_created":"Thu, 29 Jul 2010 21:00:17 +0000","
14
date_updated":"Mon, 09 Aug 2010 22:14:20 +0000",
15
"sms_url":"http:\/\/www.google.com",
16
"sms_method":"POST",
17
"sms_fallback_url":"",
18
"sms_fallback_method":"POST",
19
"capabilities": {
20
"voice":true,
21
"sms":true
22
},
23
"status_callback":null,
24
"status_callback_method":null,
25
"api_version":"2008-08-01",
26
"uri":"\/2010-04-01\/Accounts\/AC228ba7a5fe4238be081ea6f3c44186f3\/IncomingPhoneNumbers\/PNd6b0e1e84f7b117332aed2fd2e5bbcab.json"
27
}
28
],
29
"page":0,
30
"num_pages":1,
31
"page_size":50,
32
"total":2,
33
"start":0,
34
"end":1,
35
"uri":"\/2010-04-01\/Accounts\/AC228ba7a5fe4238be081ea6f3c44186f3\/IncomingPhoneNumbers.json",
36
"first_page_uri":"\/2010-04-01\/Accounts\/AC228ba7a5fe4238be081ea6f3c44186f3\/IncomingPhoneNumbers.json?Page=0&PageSize=50",
37
"previous_page_uri":null,
38
"next_page_uri":null,
39
"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

1
<TwilioResponse>
2
<Account>
3
<Sid>AC228ba7a5fe4238be081ea6f3c44186f3</Sid>
4
<FriendlyName>folly@folly.com's Account</FriendlyName>
5
<Status>Active</Status>
6
<DateCreated>Tue, 27 Jul 2010 01:54:11 +0000</DateCreated>
7
<DateUpdated>Thu, 29 Jul 2010 20:59:01 +0000</DateUpdated>
8
<AuthToken>f9dd7f4177babe34369f719e1d76c0df</AuthToken>
9
<Uri>/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3</Uri>
10
<SubresourceUris>
11
<AvailablePhoneNumbers>/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/AvailablePhoneNumbers.xml</AvailablePhoneNumbers>
12
<Calls>/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/Calls.xml</Calls>
13
...
14
</SubresourceUris>
15
</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

1
<html>
2
<head><title>200</title></head>
3
<body class="twilio-response">
4
<div class="account">
5
<h1>Account</h1>
6
<dl>
7
<dt>sid</dt>
8
<dd>AC228ba7a5fe4238be081ea6f3c44186f3</dd>
9
<dt>friendly-name</dt>
10
<dd>folly@folly.com's Account</dd>
11
<dt>status</dt>
12
<dd>Active</dd>
13
<dt>date-created</dt>
14
<dd>Tue, 27 Jul 2010 01:54:11 +0000</dd>
15
<dt>date-updated</dt>
16
<dd>Thu, 29 Jul 2010 20:59:01 +0000</dd>
17
<dt>auth-token</dt>
18
<dd>f9dd7f4177babe34369f719e1d76c0df</dd>
19
<dt>uri</dt>
20
<dd><a href="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3.html">/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3.html</a></dd>
21
<dt>subresource-uris</dt>
22
<dd>
23
<dl class="subresource-uris">
24
<dt>available-phone-numbers</dt>
25
<dd><a href="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/AvailablePhoneNumbers.html">/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/AvailablePhoneNumbers.html</a></dd>
26
<dt>calls</dt>
27
<dd><a href="/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/Calls.html">/2010-04-01/Accounts/AC228ba7a5fe4238be081ea6f3c44186f3/Calls.html</a></dd>
28
<dt>conferences</dt>
29
...
30
</dl></dd>
31
</dl>
32
</div>
33
</body>
34
</html>

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.