You are viewing the Legacy Marketing Campaigns API reference. For guidance migrating to the current version of Marketing Campaigns, see Migrating from Legacy Marketing Campaigns
You can use this endpoint only after your system has been upgraded. Learn more about the updates to the SendGrid Legacy API.
You can export recipients, get all existing exports, or check the export status using the /v3/contactdb/exports
and /v3/contactdb/exports/{id}
endpoints.
Use this endpoint to export lists or segments of recipients.
If you would just like to have a link to the exported list sent to your email set the notifications.email
option to true
in the POST
payload.
If you would like to download the list, take the id
that is returned and use the "Export Recipients Status" endpoint to get the urls
. Once you have the list of URLs, make a GET
request to each URL provided to download your CSV file(s).
You specify the segments and or/recipient lists you wish to export by providing the relevant IDs in, respectively, the segment_ids
and list_ids
fields in the request body.
The lists will be provided in either JSON or CSV files. To specify which of these you would required, set the request body file_type
field to json
or csv
.
You can also specify a maximum file size (in MB). If the export file is larger than this, it will be split into multiple files.
Bearer <<YOUR_API_KEY_HERE>>
application/json
Optional
IDs of the recipient lists you want to export.
Optional
IDs of the recipient segments you want to export.
Optional
Optional
File type for export file. Choose from json
or csv
.
csv
Possible values: csv
json
Optional
The maximum size of an export file in MB. Note that when this option is specified, multiple output files may be returned from the export.
5000
Optional
Optional
The ID of the export job.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const request = {5url: `/v3/contactdb/exports`,6method: "POST",7};89client10.request(request)11.then(([response, body]) => {12console.log(response.statusCode);13console.log(response.body);14})15.catch((error) => {16console.error(error);17});