Import Contacts
POST /v1/contacts/imports
| Property | Value |
|---|---|
| Operation | create_contact_import |
| 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.import.create (mutation) |
| Released in | 1.61.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Queues an import of at most 10,000 Contacts (a target), each upserted as POST /v1/contacts/upsert matches it, and answers 202 with the import and its Location (1.61.0). The rows are encrypted under the Organization data key, stored and deleted within 7 days of processing (a target); the report names failed rows by number and code only.
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/imports" \
-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/imports`, {
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/imports",
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: ContactImportRequest.
| Field | Type | Required | Description |
|---|---|---|---|
contacts | array of ContactCreateRequest | yes | At most 10000 rows (a target), each upserted as POST /v1/contacts/upsert matches it. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
202 | application/json | ContactImport | |
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 202 answer
The shape is ContactImport.
| Field | Type | Required | Description |
|---|---|---|---|
counts | ContactImportCounts | yes | |
created_at | Timestamp | yes | |
created_by | ActorRef | yes | |
environment | Environment | yes | |
error_code | string or null | yes | Why a failed import read nothing; null otherwise. |
errors | array of ContactImportRowError | yes | The first 100 failed rows (a target), in row order. |
finished_at | Timestamp or null | yes | |
id | ContactImportId | yes | |
kind | ContactImportKind | yes | |
object | "contact_import" | yes | |
started_at | Timestamp or null | yes | |
status | ContactImportStatus | yes |