The most up-to-date documentation for the Cloud Humans APIs is at docs.cloudhumans.com/api-reference. If this article and the reference differ, the reference prevails.
When to use
- You have the same customer duplicated across two contacts (e.g., they came in through different channels) and want to combine them into one
- You are deduplicating your contact base through an integration
- You want to consolidate the history (conversations, messages, notes) of two contacts into a single record
Prerequisites
-
Your API Key at hand — see How to find your API Key in Cloud Chat
-
CLOUDCHAT_DOMAINandACCOUNT_ID -
The two contact
ids to be merged — to find them, use the search described in How to query contacts, tickets and messages in real time via API
Endpoint
POST https://{CLOUDCHAT_DOMAIN}/api/v1/accounts/{ACCOUNT_ID}/actions/contact_merge
Headers
| Header | Value |
|---|---|
content-type |
application/json |
api_access_token |
Your API token |
Request body
{
"base_contact_id": 100,
"mergee_contact_id": 250
}
| Field | Description |
|---|---|
base_contact_id |
Contact that remains (the winner of the merge) |
mergee_contact_id |
Contact that will be absorbed and deleted |
How it works
When merging:
-
All conversations, messages, notes, inboxes (contact_inboxes), CSAT responses and campaign events of the absorbed contact are moved to the base contact.
-
For profile fields (
name,email,phone_number,identifier,additional_attributes,custom_attributes), the base contact wins. Where the base contact is empty, the value from the absorbed contact is used. -
The absorbed contact (
mergee_contact_id) is deleted at the end. -
Response 200 with the resulting base contact.
Merging is irreversible. An internal audit record is kept, but there is no "undo". Confirm which id is the base_contact_id (the one that remains) before calling — swapping the two deletes the wrong contact.
Request example
curl -X POST \
'https://{CLOUDCHAT_DOMAIN}/api/v1/accounts/{ACCOUNT_ID}/actions/contact_merge' \
--header 'content-type: application/json' \
--header 'api_access_token: SEU_TOKEN' \
--data '{
"base_contact_id": 100,
"mergee_contact_id": 250
}'
Common errors
| Status | Meaning |
|---|---|
404 Not Found |
One of the contacts (base_contact_id or mergee_contact_id) does not exist in the account |
422 Unprocessable Entity |
Invalid payload (missing base_contact_id or mergee_contact_id) |
Notes
-
Create, update and delete individual contacts: How to create, update and delete contacts via API
-
Find contact
ids: How to query contacts, tickets and messages in real time via API -
Overview of all available APIs: Master Guide — How to access and operate Cloud Chat data via API