Skip to main content
ContactsVersion: 2021-04-15

Upsert Contact

POST/contacts/upsert

The Upsert API will adhere to the configuration defined under the “Allow Duplicate Contact” setting at the Location level. If the setting is configured to check both Email and Phone, the API will attempt to identify an existing contact based on the priority sequence specified in the setting, and will create or update the contact accordingly.

If two separate contacts already exist—one with the same email and another with the same phone—and an upsert request includes both the email and phone, the API will update the contact that matches the first field in the configured sequence, and ignore the second field to prevent duplication.

Idempotency-Key is not supported. Upsert matches an existing contact by email or phone as described above, so for requests that include an email or phone it is safer to retry than Create Contact. This does not apply when createNewIfDuplicateAllowed is set at a location that allows duplicates.

Authorizations

Authorizationstringheaderrequired

Bearer authentication header of the form Bearer <token>, where <token> is your access token.

Scope:contacts.write
Auth methods:OAuthPrivate Integration
Token type:Sub-Account Token

Request​

Headers

Versionstringrequired

API Version. Send 2021-07-28.

Available options2021-04-15
Example:2021-07-28

Body

firstNamestringnullable

First name of the contact

Example:Rosan
lastNamestringnullable

Last name of the contact

Example:Deo
namestringnullable

Full name of the contact

Example:Rosan Deo
emailstringnullable

Email address of the contact

locationIdstringrequired

Location Id the contact should be created under

Example:ve9EPM428h8vShlRW1KT
genderstringdeprecated

Gender of the contact. Before v4, Create, Update and Upsert accept it, and the contact returned by Get, lookup, duplicate search and the write responses includes it; Search results do not. Deprecated: from v4 on it is neither accepted nor returned, so store gender in a contact custom field instead.

Example:male
phonestringnullable

Phone number of the contact.

Phone numbers in phone and additionalPhones are saved in E.164 format, for example +14155550123. Send E.164 when you can. A number without a country code is read as a number in the country you send. If you do not send country, the contact's saved country is used on update, then the location's country, then US. Spaces, dashes and brackets are removed.

Example:+14155550123
address1stringnullable

Street address of the contact

Example:3535 1st St N
citystringnullable

City of the contact

Example:Dolomite
statestringnullable

State of the contact

Example:AL
postalCodestringnullable

Postal code of the contact. A number is saved as a string. On update, send null to remove it. An empty string leaves it unchanged.

Example:35061
websitestringnullable

Website URL of the contact

Example:https://www.tesla.com
timezonestringnullable

Timezone of the contact

Example:America/Chihuahua
dndboolean

Global Do Not Disturb switch for all channels; true blocks every channel irrespective of current dndSettings, and it does not add or change any dndSettings entry

Example:true
dndSettingsobject

Per-channel DND settings, independent of the global dnd switch; channel keys are Call, Email, SMS, WhatsApp, GMB and FB on this Version, and lowercase keys are rejected with 422.

Channels you leave out keep their current status. The permanent status is normally set by the platform, for example after an SMS opt-out. Through this API:

  • Create Contact, and Upsert when it creates a contact, reject permanent on any channel with 401.
  • Update Contact, and Upsert when it updates a contact, can set Email to permanent and can change a permanent Email back to active or inactive.
  • Changing SMS or WhatsApp to or from permanent returns 401. Changing Call, GMB or FB to or from permanent returns 400.
  • Sending permanent for a channel that is already permanent is accepted. The status stays permanent, and the message and code of the channel are replaced with the values you send.
Example
{
  "Call": {
    "status": "active",
    "message": "Do not call"
  },
  "Email": {
    "status": "inactive"
  }
}
inboundDndSettingsobject

Do Not Disturb for inbound communication from the contact, independent of dnd and dndSettings; only the all key is accepted, with status active or inactive, and any other key is rejected with 422

Example
{
  "all": {
    "status": "active",
    "message": "Do not contact me"
  }
}
tagsstring[]

Tags for the contact. When Upsert creates a contact, the contact gets these tags. When Upsert updates an existing contact, this list replaces all of the contact's tags: tags that are not in the list are removed, and an empty array removes every tag. Leave this field out to keep the current tags. Tag names are saved in lowercase, and a tag that does not exist in the location yet is created.

To add or remove tags without replacing the others, use Add Tags (POST /contacts/{contactId}/tags) or Remove Tags (DELETE /contacts/{contactId}/tags).

Example:["nisi sint commodo amet","consequat"]
customFieldsobject[]

List of custom field values to assign to the contact

Example
[
  {
    "id": "6dvNaf7VhkQ9snc5vnjJ",
    "key": "my_custom_field",
    "fieldValue": "My Text"
  }
]
sourcestring

Source from which the contact was created

Example:public api
dateOfBirthstringnullable

The birth date of the contact. Supported formats: YYYY/MM/DD, MM/DD/YYYY, YYYY-MM-DD, MM-DD-YYYY, YYYY.MM.DD, MM.DD.YYYY, YYYY_MM_DD, MM_DD_YYYY

Example:1990-09-25
countrystringnullable

Country of the contact, as an ISO 3166-1 alpha-2 code, for example US or GB. The code is not case-sensitive, and the English country name (or UK) is also accepted. Either way, the upper-case code is saved. An empty string, or any other value, is rejected with 422. A phone number sent without a country code is read as a number in this country. When a contact is created without a country, the location's country is saved, or the agency's country if the location has none.

Example:US
companyNamestringnullable

Company name of the contact

Example:DGS VolMAX
assignedTostring

User's Id

Example:y0BeYjuRIlDwsDcOHOJo
createNewIfDuplicateAllowedboolean

Set to true to always create a new contact, without looking for an existing one. This works only at a location that allows duplicate contacts (the "Allow Duplicate Contact" setting).

  • true, and the location allows duplicate contacts: Upsert creates a new contact. It does not look for a matching contact.
  • true, and the location does not allow duplicate contacts: this field is ignored. Upsert looks for a matching contact, updates it if found, and creates a new contact if not.
  • false or not sent: Upsert looks for a matching contact, updates it if found, and creates a new contact if not. This is the same whether or not the location allows duplicate contacts.

See the Upsert Contact description for how a matching contact is found.

Default:false
Example:false
typestring

Contact type. One of the options of the location's Contact Type field (lead and customer by default), matched by option value or option name, ignoring case. When Upsert creates the contact, a value that is not sent or matches no option gives the contact the first option. When Upsert updates a contact, a value that matches no option does not change the contact's type.

Example:lead

Response

Successful response. Upsert returns 201 for both outcomes: when it creates a new contact and when it matches or updates an existing one. Use the new field to tell them apart: true means a contact was created, false means an existing contact was used.

newbooleanrequired

Whether a new contact was created (true) or an existing one was updated (false)

Example:true
contactobjectrequired

The upserted contact details

traceIdstring

Unique trace identifier for this operation

Example:abc123trace