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

Export Contacts



Operation overview

operation-overview page anchor

POST/v3/marketing/contacts/exports

Base url: https://api.sendgrid.com

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>>
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 Contacts

export-contacts page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
curl

_18
const client = require('@sendgrid/client');
_18
client.setApiKey(process.env.SENDGRID_API_KEY);
_18
_18
_18
const request = {
_18
url: `/v3/marketing/contacts/exports`,
_18
method: 'POST',
_18
_18
}
_18
_18
client.request(request)
_18
.then(([response, body]) => {
_18
console.log(response.statusCode);
_18
console.log(response.body);
_18
})
_18
.catch(error => {
_18
console.error(error);
_18
});


Rate this page: