Merge a Contact into another
POST /v1/contacts/{contact_id}/merge
| Property | Value |
|---|---|
| Operation | merge_contact |
| Group | Contacts |
| Scope | contacts:write |
| Route class | control |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Audited contacts.contact.merge (mutation) |
| Released in | 1.61.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Merges the source the body names into the Contact the path names (1.61.0; section 2.5, rule 3), irreversibly: the source becomes a merged tombstone that Calls resolve through for 90 days (a target), and an Audit event names both ids; contact.merged is written. Two ids of one system are 409 contact_merge_conflict; a target that is not active is contact_not_active; the source itself or one that is not active is validation_failed (contact_merge_self, contact_merge_source_not_active).
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the contacts:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/contacts/ctc_.../merge" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "source_contact_id": "ctc_..." }'const response = await fetch(`${process.env.VOCAL_API}/v1/contacts/ctc_.../merge`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"source_contact_id": "ctc_..."
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/contacts/ctc_.../merge",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"source_contact_id": "ctc_...",
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
contact_id | path | ContactId | yes | The id of a Contact: ctc_ and the row's UUIDv7 in 26 Crockford base32 characters. Opaque and safe to log. |
idempotency-key | header | string | no | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: ContactMergeRequest.
| Field | Type | Required | Description |
|---|---|---|---|
source_contact_id | ContactId | yes | The Contact merged into the target. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
200 | application/json | ContactMerge | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
404 | application/json | ErrorEnvelope | not_found |
409 | application/json | ErrorEnvelope | idempotency_in_progress, idempotency_key_reused, contact_not_active, contact_merge_conflict |
422 | application/json | ErrorEnvelope | validation_failed |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 200 answer
The shape is ContactMerge.