Create a Contact
POST /v1/contacts
| Property | Value |
|---|---|
| Operation | create_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.create (mutation) |
| Released in | 1.61.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Creates a Contact at revision 1 (1.61.0) and writes contact.created; the answer carries no profile. An external id or an app_user identity another Contact holds is 409 contact_match_conflict, one detail per candidate naming its contact_id; an app_user identity is capability_not_available (app_user_identity_not_available); every other issue is a detail of validation_failed (ContactIssueCode).
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" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'const response = await fetch(`${process.env.VOCAL_API}/v1/contacts`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/contacts",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={},
)
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: ContactCreateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
attributes | ContactAttributes | no | |
display_name | string | no | |
external_ids | array of ExternalIdInput | no | |
identities | array of ContactIdentityInput | no | |
language | LanguageTag | no | Recorded with the source declared. |
timezone | IanaZone | no | Recorded with the source declared. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
201 | application/json | Contact | |
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, contact_match_conflict |
422 | application/json | ErrorEnvelope | validation_failed, capability_not_available |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 201 answer
The shape is Contact.
| Field | Type | Required | Description |
|---|---|---|---|
consent | ContactConsentSummary | yes | |
created_at | Timestamp | yes | |
delete_after | Timestamp or null | yes | When a deleted Contact is purged; null otherwise. |
environment | Environment | yes | |
id | ContactId | yes | |
last_activity_at | Timestamp or null | yes | The last Call, message or API write, from which contact_inactivity_days counts. |
merged_into_id | ContactId or null | yes | The survivor of a merged one. |
object | "contact" | yes | |
profile | ContactProfile or null | yes | The content; null unless the read names include=profile. |
revision | integer | yes | |
source | ContactSource | yes | |
status | ContactStatus | yes | |
updated_at | Timestamp | yes |