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

Day Resource


The Day resource allows you to download the export file containing a single day's data for your account and the requested data type.


Messages Export file format

messages-export-file-format page anchor

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.
  • timestamps like date created , date updated and date sent are in UTC and ISO 8601 format.

Calls Export file format

calls-export-file-format page anchor

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:

  • timestamps are in UTC and ISO 8601 format.
  • Price data may not be present on all messages in BulkExport
  • uri and subresource_uris will not be present.

Conferences Export file format

conferences-export-file-format page anchor

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:

  • timestamps are in UTC and ISO 8601 format.
  • 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:

  • timestamps are in UTC and ISO 8601 format.
  • uri will not be present
  • label will not be present

Resource properties
daytype: string
Not PII

The ISO 8601 format date of the resources in the file, for a UTC day


sizetype: integer

The size of the day's data file in bytes


create_datetype: string

The ISO 8601 format date when resources is created


friendly_nametype: string

The friendly name specified when creating the job


resource_typetype: string

The type of communication – Messages, Calls, Conferences, and Participants


redirect_totype: string<URI>

GET https://bulkexports.twilio.com/v1/Exports/{ResourceType}/Days/{Day}

Parameters

fetch-parameters page anchor
URI parameters
ResourceTypetype: string
Path ParameterNot PII

The type of communication – Messages, Calls, Conferences, and Participants


Daytype: string
Path ParameterNot PII

The ISO 8601 format date of the resources in the file, for a UTC day

Fetch a single file for an exported day

fetch-a-single-file-for-an-exported-day page anchor

This will get a redirection to the day's file, once you know what days are available from the list of exported days.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.bulkexports.v1.exports('Messages')
_11
.days('2020-02-02')
_11
.fetch()
_11
.then(day => console.log(day.friendlyName));

Output

_10
{
_10
"redirect_to": "https://documentation-example-twilio-bucket.s3.amazonaws.com/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_10
}

Once you have the redirection, you can fetch the file. The redirection is of the format:


_10
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


_16
{
_16
"date_updated": "2020-01-013T03:57:34Z",
_16
"date_sent": "2020-01-01T03:57:33Z",
_16
"date_created": "2020-01-01T03:57:32Z",
_16
"body": "Sent from your Twilio trial account - woot woot!!!!",
_16
"num_segments": 1,
_16
"sid": "SM32743c2e9c251806c2317dee566f6d7b",
_16
"num_media": 0,
_16
"messaging_service_sid": "MG1ef70550624e8b354860a98d787ee1f1",
_16
"account_sid": "ACa674802ceae35ad19498be749e085991",
_16
"from": "+14155551212",
_16
"error_code": null,
_16
"to": "+14155552389",
_16
"status": "delivered",
_16
"direction": "outbound-api"
_16
}

This will be repeated per message for that day.


Read multiple Day resources

read-multiple-day-resources page anchor
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.

URI parameters
ResourceTypetype: string
Path ParameterNot PII

The type of communication – Messages, Calls, Conferences, and Participants


PageSizetype: integer
Query ParameterNot PII

How many resources to return in each list page. The default is 50, and the maximum is 1000.


Pagetype: integer
Query ParameterNot PII

The page index. This value is simply for client state.


PageTokentype: string
Query ParameterNot PII

The page token. This is provided by the API.

Fetch a list of exported days

fetch-a-list-of-exported-days page anchor

This will get the list of the exported days. There will be one day json block per day of exported data.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.bulkexports.v1.exports('Messages')
_11
.days
_11
.list({limit: 20})
_11
.then(days => days.forEach(d => console.log(d.friendlyName)));

Output

_20
{
_20
"days": [
_20
{
_20
"day": "2017-04-01",
_20
"size": 100,
_20
"resource_type": "Messages",
_20
"create_date": "2017-04-02",
_20
"friendly_name": "friendly_name"
_20
}
_20
],
_20
"meta": {
_20
"page": 0,
_20
"page_size": 50,
_20
"first_page_url": "https://bulkexports.twilio.com/v1/Exports/Messages/Days?PageSize=50&Page=0",
_20
"previous_page_url": "https://bulkexports.twilio.com/v1/Exports/Messages/Days?PageSize=50&Page=0",
_20
"url": "https://bulkexports.twilio.com/v1/Exports/Messages/Days?PageSize=50&Page=0",
_20
"next_page_url": "https://bulkexports.twilio.com/v1/Exports/Messages/Days?PageSize=50&Page=1",
_20
"key": "days"
_20
}
_20
}


Rate this page: