Menu

Expand
Rate this page:

Contacts

Add or Update a Contact

PUT /v3/marketing/contacts

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

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 your contacts have been updated or added, you can use the "Get Contacts by Emails" endpoint.

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. The contact to update will be determined only by the email field and 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

  • API Key

Headers

Authorization
string
default: Bearer <<YOUR_API_KEY_HERE>>
required

Request Body

object
list_ids
array[string]

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

contacts
array[object]

One or more contacts objects that you intend to upsert. The available fields for a contact, including the required email field are described below.

maxItems: 30000minItems: 1
required
address_line_1
string

The first line of the address.

maxLength: 100
address_line_2
string

An optional second line for the address.

maxLength: 100
alternate_emails
array[string]

Additional emails associated with the contact.

maxItems: 5minItems: 0
city
string

The contact's city.

maxLength: 60
country
string

The contact's country. Can be a full name or an abbreviation.

maxLength: 50
email
string

The contact's primary email. This is required to be a valid email.

maxLength: 254
required
first_name
string

The contact's personal name.

maxLength: 50
last_name
string

The contact's family name.

maxLength: 50
postal_code
string

The contact's ZIP code or other postal code.

state_province_region
string

The contact's state, province, or region.

maxLength: 50
custom_fields
object

An object of custom field IDs and the values you want to associate with those custom fields. You can retrieve the IDs of your custom fields from the Get All Field Definitions endpoint.

string

The properties in this object are made up of a key (the custom field ID) and value you want associated with that custom field. For example {"w1": "coffee"}.

Responses

object
job_id
string

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

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

the error message

required
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

required
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

required
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
Loading Code Sample...
        
        

        Add or Update a Contact

        Rate this page:

        Need some help?

        We all do sometimes. Get help now from the Twilio SendGrid Support Team.

        Running into a coding hurdle? Lean on the wisdom of the crowd by browsing the SendGrid tag on Stack Overflow or visiting Twilio's Stack Overflow Collective.

        Loading Code Sample...
              
              
              

              Thank you for your feedback!

              Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

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

              Thanks for your feedback!

              thanks-feedback-gif