The Day resource allows you to download the export file containing a single day's data for your account and the requested data type.
Day files are stored and returned as compressed (gzip) JSON files with one record per line. Records are similar to the Message resource. The differences are:
price_units
will not be present
api_version
will not be present
error message
will not be present (but
error_code
is)
uri
and
subresource_uris
will not be present.
date created
,
date updated
and
date sent
are in UTC and ISO 8601 format.
Day files are stored and returned as compressed (gzip) JSON files with one record per line. Records are similar to the Calls resource. The differences are:
uri
and
subresource_uris
will not be present.
Day files are stored and returned as compressed (gzip) JSON files with one record per line. Records are similar to the Conferences resource. The differences are:
api_version
will not be present
uri
and
subresource_uris
will not be present.
##Participants BulkExport file format Day files are stored and returned as compressed (gzip) JSON files with one record per line. Records are similar to the Participants resource. The differences are:
uri
will not be present
label
will not be present
The type of communication – Messages, Calls, Conferences, and Participants
GET https://bulkexports.twilio.com/v1/Exports/{ResourceType}/Days/{Day}
The type of communication – Messages, Calls, Conferences, and Participants
The ISO 8601 format date of the resources in the file, for a UTC day
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchDay() {11const day = await client.bulkexports.v112.exports("Messages")13.days("2020-02-02")14.fetch();1516console.log(day.redirectTo);17}1819fetchDay();
1{2"redirect_to": "https://documentation-example-twilio-bucket.s3.amazonaws.com/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"3}
Once you have the redirection, you can fetch the file. The redirection is of the format:
https://documentation-example-twilio-bucket/daily/day%3D2020-02-02/type%3DMessages/account%3DACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/created_time%3D20200202000014/part-0XXXXXXXXXX0.json.gz?X-Amz-Security-Token=IQoXXXXXXXXH1GQ%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20200202T012341Z&X-Amz-SignedHeaders=host&X-Amz-Expires=240&X-Amz-Credential=AXXXXXXXXXXX22%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=bXXXXXXXXX9
This link is a one-time use signed S3 link to the file. You can request these links multiple times from the API above, but each link can only be used once.
The file is compressed using gzip. You can use a command line tool to gunzip the file, or utilities in your language like Java's GZIPInputStream or GZipStream in C#.
Inside the file, messages are contained, with JSON equivalent to the Message Resource. These are of the format
1{2"date_updated": "2020-01-013T03:57:34Z",3"date_sent": "2020-01-01T03:57:33Z",4"date_created": "2020-01-01T03:57:32Z",5"body": "Sent from your Twilio trial account - woot woot!!!!",6"num_segments": 1,7"sid": "SM32743c2e9c251806c2317dee566f6d7b",8"num_media": 0,9"messaging_service_sid": "MG1ef70550624e8b354860a98d787ee1f1",10"account_sid": "ACa674802ceae35ad19498be749e085991",11"from": "+14155551212",12"error_code": null,13"to": "+14155552389",14"status": "delivered",15"direction": "outbound-api"16}
This will be repeated per message for that day.
GET https://bulkexports.twilio.com/v1/Exports/{ResourceType}/Days
{ResourceType}
is the type of Twilio resource, one of Calls
or Messages
. The Developer Preview release of Day supports exporting Messages
only.
The type of communication – Messages, Calls, Conferences, and Participants
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listDay() {11const days = await client.bulkexports.v112.exports("Messages")13.days.list({ limit: 20 });1415days.forEach((d) => console.log(d.day));16}1718listDay();
1{2"days": [],3"meta": {4"page": 0,5"page_size": 50,6"first_page_url": "https://bulkexports.twilio.com/v1/Exports/Messages/Days?PageSize=50&Page=0",7"previous_page_url": null,8"url": "https://bulkexports.twilio.com/v1/Exports/Messages/Days?PageSize=50&Page=0",9"next_page_url": null,10"key": "days"11}12}