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

Add or Update a Contact



Operation overview

operation-overview page anchor

PUT/v3/marketing/contacts

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

This endpoint allows the upsert(link takes you to an external page) (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.


Authentication

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

An array of List ID strings that this contact will be added to.


contactsarray[object]required

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.

202400401403404500
Schema
Property nameTypeRequiredDescriptionChild properties
job_idstring

Indicates that the contacts are queued for processing. Check the job status with the "Import Contacts Status" endpoint.

Add or Update a Contact

add-or-update-a-contact page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
curl

_29
const client = require('@sendgrid/client');
_29
client.setApiKey(process.env.SENDGRID_API_KEY);
_29
_29
const data = {
_29
"contacts": [
_29
{
_29
"custom_fields": {
_29
"w1": "coffee",
_29
"w33": "42",
_29
"e2": "blue"
_29
}
_29
}
_29
]
_29
};
_29
_29
const request = {
_29
url: `/v3/marketing/contacts`,
_29
method: 'PUT',
_29
body: data
_29
}
_29
_29
client.request(request)
_29
.then(([response, body]) => {
_29
console.log(response.statusCode);
_29
console.log(response.body);
_29
})
_29
.catch(error => {
_29
console.error(error);
_29
});


Rate this page: