Create or update Contacts in a batch
POST /v1/contacts/upsert
| Property | Value |
|---|---|
| Operation | upsert_contacts |
| 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.upsert (mutation) |
| Released in | 1.61.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Upserts at most 1,000 Contacts (a target) by the order of section 2.5, rule 2, in one transaction per item (1.61.0), and answers one outcome per item; a conflicting or invalid item writes nothing and blocks no other. Each created Contact writes contact.created.
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/upsert" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"contacts": [
{}
]
}'const response = await fetch(`${process.env.VOCAL_API}/v1/contacts/upsert`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"contacts": [
{}
]
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/contacts/upsert",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"contacts": [
{},
],
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
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: ContactUpsertRequest.
| Field | Type | Required | Description |
|---|---|---|---|
contacts | array of ContactCreateRequest | yes | At most 1000 items (a target), each a Contact as a create names it. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
200 | application/json | ContactUpsertResult | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
409 | application/json | ErrorEnvelope | idempotency_in_progress, idempotency_key_reused |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 200 answer
The shape is ContactUpsertResult.
| Field | Type | Required | Description |
|---|---|---|---|
object | "contact_upsert" | yes | |
results | array of ContactUpsertItemResult | yes |