Skip to contentSkip to navigationSkip to topbar
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 nameTypeRequiredDescriptionChild properties
daystringOptional
Not PII

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


sizeintegerOptional

The size of the day's data file in bytes

Default: 0

create_datestringOptional

The ISO 8601 format date when resources is created


friendly_namestringOptional

The friendly name specified when creating the job


resource_typestringOptional

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


redirect_tostring<uri>Optional

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 dayLink to code sample: Fetch a single file for an exported day
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchDay() {
11
const day = await client.bulkexports.v1
12
.exports("Messages")
13
.days("2020-02-02")
14
.fetch();
15
16
console.log(day.redirectTo);
17
}
18
19
fetchDay();

Output

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.


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.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listDay() {
11
const days = await client.bulkexports.v1
12
.exports("Messages")
13
.days.list({ limit: 20 });
14
15
days.forEach((d) => console.log(d.day));
16
}
17
18
listDay();

Output

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
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.