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

Export Custom Job Resource


Custom Jobs allow you to create exports for any date range. If the date range spans multiple days, they will generate separate output days. Jobs can be deleted with the Job resource. When a Job is completed successfully, the results are visible as days in the Day resource.


ExportCustomJob Properties

exportcustomjob-properties page anchor
Resource properties
friendly_nametype: string
Not PII

The friendly name specified when creating the job


resource_typetype: string

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


start_daytype: string

The start day for the custom export specified when creating the job


end_daytype: string

The end day for the export specified when creating the job


webhook_urltype: string

The optional webhook url called on completion of the job. If this is supplied, WebhookMethod must also be supplied.


webhook_methodtype: string

This is the method used to call the webhook on completion of the job. If this is supplied, WebhookUrl must also be supplied.


emailtype: string

The optional email to send the completion notification to


job_sidtype: SID<JS>

The unique job_sid returned when the custom export was created


detailstype: object

The details of a job which is an object that contains an array of status grouped by status state. Each status object has a status string, a count which is the number of days in that status, and list of days in that status. The day strings are in the format yyyy-MM-dd. As an example, a currently running job may have a status object for COMPLETED and a status object for SUBMITTED each with its own count and list of days.


job_queue_positiontype: string

This is the job position from the 1st in line. Your queue position will never increase. As jobs ahead of yours in the queue are processed, the queue position number will decrease


estimated_completion_timetype: string

this is the time estimated until your job is complete. This is calculated each time you request the job list. The time is calculated based on the current rate of job completion (which may vary) and your job queue position

ENUM:STATUS possible values
ErrorDuringRunThe Job was attempted, but an error prevented completion. This is not a final status, the job will be retried.
SubmittedThe Job has been successfully submitted and is in the queue to execute.
RunningThe job is currently running. The output should be available shortly. Multiple Jobs may run at the same time. You can use the 'estimated_completion_time' to get a sense of when your job will be complete.
CompletedEmptyRecordsThe Job has been completed, however, no records for the requested resource have been found. An empty file will be available at the Day endpoint.
CompletedThe Job has completed, and the result files are available at the Day endpoint.
FailedThe Job was attempted, but an error prevented completion. This is a final status, as the job has already been tried multiple times and has not been successful. Try submitting the job again, or reach out to your Twilio support team if the problem continues to persist.
RunningToBeDeletedThe Job is currently running, but it has been marked for deletion and will be deleted soon.
DeletedByUserRequestThe Job has been marked for deletion. So the system will not attempt to run it.

Create an ExportCustomJob resource

create-an-exportcustomjob-resource page anchor
POST https://bulkexports.twilio.com/v1/Exports/{ResourceType}/Jobs

Parameters

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

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


Request body parameters
StartDaytype: stringRequired

The start day for the custom export specified as a string in the format of yyyy-mm-dd


EndDaytype: stringRequired

The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day.


FriendlyNametype: stringRequired

The friendly name specified when creating the job


WebhookUrltype: string

The optional webhook url called on completion of the job. If this is supplied, WebhookMethod must also be supplied. If you set neither webhook nor email, you will have to check your job's status manually.


WebhookMethodtype: string

This is the method used to call the webhook on completion of the job. If this is supplied, WebhookUrl must also be supplied.


Emailtype: string

The optional email to send the completion notification to. You can set both webhook, and email, or one or the other. If you set neither, the job will run but you will have to query to determine your job's status.

Create a new BulkExport custom job

create-a-new-bulkexport-custom-job page anchor
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
// 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 = require('twilio')(accountSid, authToken);
_18
_18
client.bulkexports.v1.exports('Messages')
_18
.exportCustomJobs
_18
.create({
_18
email: 'you@example.com',
_18
webhookMethod: 'POST',
_18
webhookUrl: 'https://www.company.com/bulkexporthook',
_18
startDay: '2019-11-20',
_18
endDay: '2019-11-30',
_18
friendlyName: 'Export1'
_18
})
_18
.then(export_custom_job => console.log(export_custom_job.jobSid));

Output

_13
{
_13
"start_day": "2019-11-20",
_13
"job_sid": "JSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_13
"friendly_name": "Export1",
_13
"webhook_method": "POST",
_13
"details": {},
_13
"end_day": "2019-11-30",
_13
"webhook_url": "https://www.company.com/bulkexporthook",
_13
"email": "you@example.com",
_13
"resource_type": "Messages",
_13
"job_queue_position": "1",
_13
"estimated_completion_time": "2021-03-15T20:20:14.547"
_13
}


Read multiple ExportCustomJob resources

read-multiple-exportcustomjob-resources page anchor
GET https://bulkexports.twilio.com/v1/Exports/{ResourceType}/Jobs

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.

Read the current list of export jobs for this resource type

read-the-current-list-of-export-jobs-for-this-resource-type page anchor
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
.exportCustomJobs
_11
.list({limit: 20})
_11
.then(exportCustomJobs => exportCustomJobs.forEach(e => console.log(e.friendlyName)));

Output

_26
{
_26
"meta": {
_26
"previous_page_url": "https://bulkexports.twilio.com/v1/Exports/Messages/Jobs?PageSize=50&Page=0",
_26
"url": "https://bulkexports.twilio.com/v1/Exports/Messages/Jobs?PageSize=50&Page=0",
_26
"page_size": 50,
_26
"key": "jobs",
_26
"first_page_url": "https://bulkexports.twilio.com/v1/Exports/Messages/Jobs?PageSize=50&Page=0",
_26
"next_page_url": "https://bulkexports.twilio.com/v1/Exports/Messages/Jobs?PageSize=50&Page=1",
_26
"page": 0
_26
},
_26
"jobs": [
_26
{
_26
"start_day": "start_day",
_26
"job_sid": "JSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_26
"friendly_name": "friendly_name",
_26
"webhook_method": "webhook_method",
_26
"details": {},
_26
"end_day": "end_day",
_26
"webhook_url": "webhook_url",
_26
"email": "email",
_26
"resource_type": "resource_type",
_26
"job_queue_position": "1",
_26
"estimated_completion_time": "2021-03-15T20:20:14.547"
_26
}
_26
]
_26
}


Rate this page: