nodejs

Choose Language

Exports Calls

/exports/info.json

Returns information about an export job. If the export job's state is 'complete', the returned data will include a URL you can use to fetch the results. Every export job produces a zip archive, but the format of the archive is distinct for each job type. The api calls that initiate exports include more details about the output format for that job type.

Example Call

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY'); var id = "example id"; mandrill_client.exports.info({"id": id}, function(result) { console.log(result); /* { "id": "2013-01-01 12:20:28.13842", "created_at": "2013-01-01 12:30:28", "type": "activity", "finished_at": "2013-01-01 12:35:52", "state": "working", "result_url": "http://exports.mandrillapp.com/example/export.zip" } */ }, function(e) { // Mandrill returns the error as an object with name and message keys console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message); // A mandrill error occurred: Invalid_Key - Invalid API key });
Parameters
id* string an export job identifier
Return Value
struct the information about the export
id string the unique identifier for this Export. Use this identifier when checking the export job's status
created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
type string the type of the export job - activity, reject, or whitelist
finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format
state string the export job's state - waiting, working, complete, error, or expired.
result_url string the url for the export job's results, if the job is completed.
Errors
Unknown_Export The requested export job does not exist
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/exports/list.json

Returns a list of your exports.

Example Call

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY'); mandrill_client.exports.list({}, function(result) { console.log(result); /* [{ "id": "2013-01-01 12:20:28.13842", "created_at": "2013-01-01 12:30:28", "type": "activity", "finished_at": "2013-01-01 12:35:52", "state": "working", "result_url": "http://exports.mandrillapp.com/example/export.zip" }] */ }, function(e) { // Mandrill returns the error as an object with name and message keys console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message); // A mandrill error occurred: Invalid_Key - Invalid API key });
Parameters
No parameters
Return Value
array the account's exports
return[] struct the individual export info
id string the unique identifier for this Export. Use this identifier when checking the export job's status
created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
type string the type of the export job - activity, reject, or whitelist
finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format
state string the export job's state - waiting, working, complete, error, or expired.
result_url string the url for the export job's results, if the job is completed.
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/exports/rejects.json

Begins an export of your rejection blacklist. The blacklist will be exported to a zip archive containing a single file named rejects.csv that includes the following fields: email, reason, detail, created_at, expires_at, last_event_at, expires_at.

Example Call

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY'); var notify_email = "notify_email@example.com"; mandrill_client.exports.rejects({"notify_email": notify_email}, function(result) { console.log(result); /* { "id": "2013-01-01 12:20:28.13842", "created_at": "2013-01-01 12:30:28", "type": "reject", "finished_at": null, "state": "waiting", "result_url": null } */ }, function(e) { // Mandrill returns the error as an object with name and message keys console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message); // A mandrill error occurred: Invalid_Key - Invalid API key });
Parameters
notify_email string an optional email address to notify when the export job has finished.
Validation: email
Return Value
struct information about the rejects export job that was started
id string the unique identifier for this Export. Use this identifier when checking the export job's status
created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
type string the type of the export job
finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format, or null for jobs that have not run
state string the export job's state
result_url string the url for the export job's results, if the job is complete
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/exports/whitelist.json

Begins an export of your rejection whitelist. The whitelist will be exported to a zip archive containing a single file named whitelist.csv that includes the following fields: email, detail, created_at.

Example Call

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY'); var notify_email = "notify_email@example.com"; mandrill_client.exports.whitelist({"notify_email": notify_email}, function(result) { console.log(result); /* { "id": "2013-01-01 12:20:28.13842", "created_at": "2013-01-01 12:30:28", "type": "reject", "finished_at": null, "state": "waiting", "result_url": null } */ }, function(e) { // Mandrill returns the error as an object with name and message keys console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message); // A mandrill error occurred: Invalid_Key - Invalid API key });
Parameters
notify_email string an optional email address to notify when the export job has finished.
Validation: email
Return Value
struct information about the whitelist export job that was started
id string the unique identifier for this Export. Use this identifier when checking the export job's status
created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
type string the type of the export job
finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format, or null for jobs that have not run
state string the export job's state
result_url string the url for the export job's results, if the job is complete
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/exports/activity.json

Begins an export of your activity history. The activity will be exported to a zip archive containing a single file named activity.csv in the same format as you would be able to export from your account's activity view. It includes the following fields: Date, Email Address, Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom metadata fields, they will be included in the exported data.

Example Call

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY'); var notify_email = "notify_email@example.com"; var date_from = "2013-01-01 12:53:01"; var date_to = "2013-01-06 13:42:18"; var tags = [ "example-tag" ]; var senders = [ "test@example.com" ]; var states = [ "sent" ]; var api_keys = [ "ONzNrsmbtNXoIKyfPmjnig" ]; mandrill_client.exports.activity({"notify_email": notify_email, "date_from": date_from, "date_to": date_to, "tags": tags, "senders": senders, "states": states, "api_keys": api_keys}, function(result) { console.log(result); /* { "id": "2013-01-01 12:20:28.13842", "created_at": "2013-01-01 12:30:28", "type": "reject", "finished_at": null, "state": "waiting", "result_url": null } */ }, function(e) { // Mandrill returns the error as an object with name and message keys console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message); // A mandrill error occurred: Invalid_Key - Invalid API key });
Parameters
notify_email string an optional email address to notify when the export job has finished
Validation: email
date_from string start date as a UTC string in YYYY-MM-DD HH:MM:SS format
date_to string end date as a UTC string in YYYY-MM-DD HH:MM:SS format
tags array an array of tag names to narrow the export to; will match messages that contain ANY of the tags
tags[] string a tag name
senders array an array of senders to narrow the export to
senders[] string a sender address
email
states array an array of states to narrow the export to; messages with ANY of the states will be included
states[] string a message state
oneof(sent, rejected, bounced, soft-bounced, spam, unsub)
api_keys array an array of api keys to narrow the export to; messsagse sent with ANY of the keys will be included
api_keys[] string an API key associated with your account
Return Value
struct information about the activity export job that was started
id string the unique identifier for this Export. Use this identifier when checking the export job's status
created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
type string the type of the export job
finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format, or null for jobs that have not run
state string the export job's state
result_url string the url for the export job's results, if the job is complete
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.