This endpoint allows the upsert (insert or update) of up to 30,000 contacts, or 6MB of data, whichever is lower.
Because the creation and update of contacts is an asynchronous process, the response will not contain immediate feedback on the processing of your upserted contacts. Rather, it will contain an HTTP 202 response indicating the contacts are queued for processing or an HTTP 4XX error containing validation errors. Should you wish to get the resulting contact's ID or confirm that your contacts have been updated or added, you can use the Get Contacts by Identifiers operation.
Please note that custom fields need to have been already created if you wish to set their values for the contacts being upserted. To do this, please use the Create Custom Field Definition endpoint.
You will see a job_id
in the response to your request. This can be used to check the status of your upsert job. To do so, please use the Import Contacts Status endpoint.
If the contact already exists in the system, any entries submitted via this endpoint will update the existing contact. In order to update a contact, all of its existing identifiers must be present. Any fields omitted from the request will remain as they were. A contact's ID cannot be used to update the contact.
The email field will be changed to all lower-case. If a contact is added with an email that exists but contains capital letters, the existing contact with the all lower-case email will be updated.
Bearer <<YOUR_API_KEY_HERE>>
application/json
Optional
An array of List ID strings that this contact will be added to.
One or more contacts objects that you intend to upsert. Each contact needs to include at least one of email
, phone_number_id
, external_id
, or anonymous_id
as an identifier.
Indicates that the contacts are queued for processing. Check the job status with the "Import Contacts Status" endpoint.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const data = {5contacts: [6{7custom_fields: {8w1: "coffee",9w33: "42",10e2: "blue",11},12},13],14};1516const request = {17url: `/v3/marketing/contacts`,18method: "PUT",19body: data,20};2122client23.request(request)24.then(([response, body]) => {25console.log(response.statusCode);26console.log(response.body);27})28.catch((error) => {29console.error(error);30});