Menu

Contacts

Export Contacts

Export Contacts

POST /marketing/contacts/exports

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

  • API Key

Headers

Authorization
string
default: Bearer <<YOUR_API_KEY_HERE>>
required

Request Body

object
list_ids
array[string]

IDs of the contact lists you want to export.

segment_ids
array[string]

IDs of the contact segments you want to export.

notifications
object
email
boolean
file_type
string

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

default: csvAllowed Values: csv, json
max_file_size
integer

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

Responses

object
_metadata
object
required
prev
string

The URL of the previous page of results. If this field isn't present, you're at the start of the list.

format: uri
self
string

The URL of the current page of results.

format: uri
next
string

The URL of the next page of results. If this field isn't present, you're at the end of the list.

format: uri
count
number

The number of items in the entire list, i.e., across all pages.

id
string

The ID of the export job.

object
errors
array[object]
message
string
field
string
error_id
string
parameter
string
object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
message
string
Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the SendGrid tag on Stack Overflow.

Thank you for your feedback!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

Refer us and get $10 in 3 simple steps!

Step 1

Get link

Get a free personal referral link here

Step 2

Give $10

Your user signs up and upgrade using link

Step 3

Get $10

1,250 free SMSes
OR 1,000 free voice mins
OR 12,000 chats
OR more