Skip to contentSkip to navigationSkip to topbar
On this page

Export Contacts



Operation overview

operation-overview page anchor

POST/v3/marketing/contacts/exports

Base url: https://api.sendgrid.com (The Twilio SendGrid v3 API)

Use this endpoint to export lists or segments of contacts.

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 Contacts 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/contact 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.


Authentication

authentication page anchor
Property nameTypeRequiredDescription
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>
Encoding type:application/json
Schema
Property nameTypeRequiredDescriptionChild properties
list_idsarray[string<uuid>]Optional

IDs of the contact lists you want to export.


segment_idsarray[string]Optional

IDs of the contact segments you want to export.


notificationsobjectOptional

file_typeenum<string>Optional

File type for export file. Choose from json or csv.

Default: csvPossible values:
csvjson

max_file_sizeintegerOptional

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.

Default: 5000
202400401403404500
Schema
Property nameTypeRequiredDescriptionChild properties
_metadataobject

idstring

The ID of the export job.

Export ContactsLink to code sample: Export Contacts
1
const client = require('@sendgrid/client');
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
5
const request = {
6
url: `/v3/marketing/contacts/exports`,
7
method: 'POST',
8
9
}
10
11
client.request(request)
12
.then(([response, body]) => {
13
console.log(response.statusCode);
14
console.log(response.body);
15
})
16
.catch(error => {
17
console.error(error);
18
});

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.