SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site,, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Exporting SMS and Call Logs

First, let’s make sure you are in the right place. Are you looking for raw call and SMS logs? Or, are you looking for analytics? If you are looking for metrics, reporting, data analysis, etc., please check out Messaging Insights or Calls Insights as a first step, or see our FAQ on doing analytics on Twilio data for additional options.

If you’re looking to do a raw export, you’ve come to the right place.

Table of Contents

Bulk Exporting via Console or API

Twilio offers bulk exporting of data from Console and the API.

The Bulk Export Console experience is the simplest way to export more than 10,000 records for Messaging, or more than 2,500 Voice call records.

You can find the Bulk Export feature in Console for Messaging and Voice in these locations:

In addition, the BulkExport API provides an efficient mechanism for retrieving all of your activity logs from the Twilio platform on an ongoing basis, or for one-off downloads. To learn more see Bulk Export API Overview.

Exporting up to 10,000 records from the Message Logs page in Console

You can export up to 10,000 message log records from the Message Logs page in Twilio Console, by clicking Export to CSV at the top right of the page.

Exporting up to 2,500 records from the Call Logs page in Console

Visit the Call Logs page and click the Export CSV button to export up to 2,500 call logs using the Console.

Exporting up to 1000 records

To retrieve the last 1000 call records from your logs:

  1. Copy this URL into a text editor:
  2. 'AC12345' is a fake Account SID, so please replace it with your own Account SID
  3. Paste the modified URL from your text editor into the URL bar of your browser and press "Enter"
  4. You'll be prompted for two fields: "Username" and "Password." For "Username," enter your account SID. For "Password," enter your auth token.

Congratulations, you just made a GET request to the Calls list resource! A CSV should now be downloading. You can download your SMS logs by repeating the same process but using this URL instead:

This makes a GET request to the Messages List resource.

Refining this search

The request we just made above asks Twilio to download all calls or messages from your project. But what if you just wanted to look at a subset of these records?

For example, let's say you want to look only at calls to your Twilio number (781) 333-4444, or all messages sent on June 1st, 2012. Twilio supports filters such as "To", "From", "StartTime" (for calls), "DateSent" (for SMS messages), and more. You can append these to your query like this: 

To see all your filtering options for exporting logs, see our Calls list documentation and our Messages list documentation.

Getting lots of data

If you are going to be downloading lots of data from the Twilio API, we highly suggest that you use one of the Twilio CLI or Twilio Helper Libraries to do this.

Twilio CLI Example with Bash

Using a Bash script with the Twilio CLI can be useful if you are looking to quickly create a list of messages with low environment setup. Install the Twilio CLI and log in via the CLI before running the following command:

twilio api:core:messages:list --no-limit --properties="sid,from,to,body,status,direction" \
| while read -r row ; do
echo "$row" >> data.tsv

For the full list of message properties that can be included, see the Twilio Message Resource documentation page.

PHP Code Sample

Here is a simple example of how the PHP Helper Library can be used to download data a CSV of SMS your records. If you find this example timing out, or taking to long, try shortening the time interval of the DateSent filters.

* Download the library from:
* Copy the 'Twilio' folder into a directory containing this file.

require __DIR__ . '/Twilio/autoload.php';

use Twilio\Rest\Client;

/* Your Twilio account sid and auth token */
$account_sid = "ACXXXXXXXXX";
$auth_token = "YYYYYYYYYYYY";

/* Download data from Twilio API */
$client = new Client($account_sid, $auth_token);
$messages = $client->messages->stream(
  'dateSentAfter' => '2015-05-01',
  'dateSentBefore' => '2015-06-01'

/* Browser magic */
$filename = $account_sid."_sms.csv";
header("Content-Type: application/csv");
header("Content-Disposition: attachment; filename={$filename}");

/* Write headers */
$fields = array( 'SMS Message SID', 'From', 'To', 'Date Sent', 'Status', 'Direction', 'Price', 'Body' );
echo '"'.implode('","', $fields).'"'."\n";

/* Write rows */
foreach ($messages as $sms) {
  $row = array(
    $sms->dateSent->format('Y-m-d H:i:s'),

  echo '"'.implode('","', $row).'"'."\n";

If you prefer not to use the official Helper Libraries, then you're going to need to design your application to make use of the built-in nextpageuri attribute which Twilio's API provides. The nextpageuri is a URL which keeps track of which call or SMS was the last record you fetched and is designed to guide your application through the paging process.

There isn't a nextpageuri in .CSV format, so if you plan on getting extremely recent records in CSV, you will need to pull the records in either XML or JSON and convert the results to CSV.


Have more questions? Submit a request
Powered by Zendesk