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

Property nameTypePIIDescription
daystring
Not PII

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


sizeinteger

The size of the day's data file in bytes


create_datestring

The ISO 8601 format date when resources is created


friendly_namestring

The friendly name specified when creating the job


resource_typestring

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


redirect_tostring<uri>

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

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
ResourceTypestringrequired

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


Daystringrequired

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

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function fetchDay() {
_19
const day = await client.bulkexports.v1
_19
.exports("Messages")
_19
.days("2020-02-02")
_19
.fetch();
_19
_19
console.log(day.redirectTo);
_19
}
_19
_19
fetchDay();

Output

_10
{
_10
"redirect_to": "https://documentation-example-twilio-bucket.s3.amazonaws.com/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_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.

Property nameTypeRequiredPIIDescription
ResourceTypestringrequired

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

Property nameTypeRequiredPIIDescription
PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageintegerOptional

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

Minimum: 0

PageTokenstringOptional

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

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

Output

_12
{
_12
"days": [],
_12
"meta": {
_12
"page": 0,
_12
"page_size": 50,
_12
"first_page_url": "https://bulkexports.twilio.com/v1/Exports/Messages/Days?PageSize=50&Page=0",
_12
"previous_page_url": null,
_12
"url": "https://bulkexports.twilio.com/v1/Exports/Messages/Days?PageSize=50&Page=0",
_12
"next_page_url": null,
_12
"key": "days"
_12
}
_12
}


Rate this page: