Export a Campaign's enrollments
POST /v1/campaigns/{campaign_id}/exports
| Property | Value |
|---|---|
| Operation | export_campaign |
| Group | Campaigns |
| Scope | campaigns:read |
| Route class | control |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Audited campaigns.campaign.export (mutation) |
| Released in | 1.65.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Creates a campaign.export job that writes the enrollments of a Campaign to a file of ids, statuses, dispositions, attempts and Call and Outcome ids, never Contact details, and answers 202 with the job and its Location (1.65.0; section 7.4). In PHI mode only an auditor Member may export (forbidden with auditor_required); an Audit event.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the campaigns:read scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/campaigns/cmp_.../exports" \
-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/campaigns/cmp_.../exports`, {
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/campaigns/cmp_.../exports",
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 |
|---|---|---|---|---|
campaign_id | path | CampaignId | yes | The id of a Campaign: cmp_ 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: CampaignExportRequest.
| Field | Type | Required | Description |
|---|---|---|---|
format | one of "csv", "jsonl" | no | csv when omitted. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
202 | application/json | Job | |
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 |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 202 answer
The shape is Job.
| Field | Type | Required | Description |
|---|---|---|---|
created_at | Timestamp | yes | |
created_by | ActorRef | yes | |
error | JobError or null | yes | Why the job failed, a code and a message; null otherwise. |
finished_at | Timestamp or null | yes | |
has_result_file | boolean | yes | True when the result is a file, fetched through POST /v1/jobs/{job_id}/result-url. |
id | JobId | yes | |
object | "job" | yes | |
progress | JobProgress | yes | |
resource | JobResource or null | yes | |
result | JobResult or null | yes | A small result inline once succeeded, typed by the job type (WebhookReplayJobResult for webhook.replay, from 1.53.0 KnowledgeEvaluationJobResult for knowledge.evaluation, from 1.55.0 PromptEvalRunJobResult for prompt.evaluation and agent.conversation_test, from 1.56.0 AnalysisJobResult for call.analyze); null before. |
started_at | Timestamp or null | yes | |
status | JobStatus | yes | |
type | JobType | yes |