Skip to contentSkip to navigationSkip to topbar
On this page

Add or Update a Contact



Operation overview

operation-overview page anchor

PUT/v3/marketing/contacts

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

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>>
Encoding type:application/json
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 ContactLink to code sample: Add or Update a Contact
1
const client = require("@sendgrid/client");
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const data = {
5
contacts: [
6
{
7
custom_fields: {
8
w1: "coffee",
9
w33: "42",
10
e2: "blue",
11
},
12
},
13
],
14
};
15
16
const request = {
17
url: `/v3/marketing/contacts`,
18
method: "PUT",
19
body: data,
20
};
21
22
client
23
.request(request)
24
.then(([response, body]) => {
25
console.log(response.statusCode);
26
console.log(response.body);
27
})
28
.catch((error) => {
29
console.error(error);
30
});

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.