Skip to navigation

Create and start a campaign

Prepare recipients, plan, admit and start calls, then read progress and results.

A campaign calls a recipient list with a published agent. Creating a campaign saves a draft. To start dialing, move it through plan → admit → start. Each command needs the campaign’s current ETag in If-Match and a separate Idempotency-Key.

The examples use RASEN_API_BASE and RASEN_API_KEY from the Quickstart. You need calls.write for changes and calls.read for campaign and recipient reads. Publish the agent and configure an outbound number first (Telephony connections, Phone routing).

1. Create a draft

Save a new idempotency key before sending the request. Keep it for retries of this same action.

CREATE_KEY=$(uuidgen)
curl --fail-with-body -sS -D campaign-headers.txt -o campaign.json \
-X POST "$RASEN_API_BASE/campaigns" \
-H "Authorization: Bearer $RASEN_API_KEY" -H "Idempotency-Key: $CREATE_KEY" \
-H "Content-Type: application/json" \
-d '{"agent_id": "agent_…", "name": "Appointment reminders",
"recipients": [{"to_e164": "+12025550123", "contact_ref": "appointment-001",
"variables": {"customer_name": "Alex"}}],
"max_attempts_per_recipient": 1, "max_concurrent_calls": 1,
"dialing_time_zone": "UTC"}'

The 201 response contains the campaign id, revision and state, plus an ETag header. Use that id as CAMPAIGN_ID. Inline campaigns accept 1 to 100,000 recipients. Each recipient requires to_e164; optional variables contain at most 64 string values.

Optional settings include from_phone_number_id, retry count and backoff, concurrency, ringing timeout, a dialing time zone, and absolute or daily dialing windows. The accepted concurrency range is 1 to 1,000; workspace capacity and admission policy still apply.

2. Plan and admit

Use the ETag from creation or GET /campaigns/{campaign_id} for planning. Each successful command returns a new ETag; use it for the next command. After a lost response, retry with the same key and the original request. After a stale revision refusal, read and review the campaign again.

PLAN_KEY=$(uuidgen)
curl --fail-with-body -sS -D plan-headers.txt -X POST \
"$RASEN_API_BASE/campaigns/$CAMPAIGN_ID/plan" \
-H "Authorization: Bearer $RASEN_API_KEY" \
-H "If-Match: $ETAG_FROM_CREATE" -H "Idempotency-Key: $PLAN_KEY"
ADMIT_KEY=$(uuidgen)
curl --fail-with-body -sS -D admit-headers.txt -X POST \
"$RASEN_API_BASE/campaigns/$CAMPAIGN_ID/admit" \
-H "Authorization: Bearer $RASEN_API_KEY" \
-H "If-Match: $ETAG_FROM_PLAN" -H "Idempotency-Key: $ADMIT_KEY"

Planning returns progress, capacity ceiling and dialing-window information. Admission checks whether the planned campaign can proceed. Do not send start after a refused plan or admission.

3. Start dialing

This operation starts real outbound calls. Use the ETag returned by admission.

START_KEY=$(uuidgen)
curl --fail-with-body -sS -X POST "$RASEN_API_BASE/campaigns/$CAMPAIGN_ID/start" \
-H "Authorization: Bearer $RASEN_API_KEY" \
-H "If-Match: $ETAG_FROM_ADMIT" -H "Idempotency-Key: $START_KEY"

In the docs, open API Reference → Campaigns → Start an admitted campaign and select Try it. Provide your key, campaign ID, current ETag and a new idempotency key.

Recipient files

POST /campaigns/recipients/check validates and previews a CSV or XLSX file without creating a campaign. POST /campaigns/upload creates one from a file. Both use multipart form data with a recipients file field; upload also requires agent_id and name and takes an idempotency key. Use the API Reference for the full form fields and validation report.

curl --fail-with-body -sS -X POST "$RASEN_API_BASE/campaigns/recipients/check" \
-H "Authorization: Bearer $RASEN_API_KEY" -F "recipients=@recipients.csv"

Progress and controls

Read GET /campaigns, GET /campaigns/{campaign_id} and GET /campaigns/{campaign_id}/recipients. Lists use limit and next_cursor.

CommandPurpose
POST …/pausePause a dialing campaign.
POST …/resumeResume a paused campaign.
POST …/retryRetry selected outcomes; send a JSON body with optional dispositions.
POST …/cancelCancel a campaign.
POST /campaign-suppressionsSuppress a destination with to_e164 and reason do_not_call or opt_out.

State commands require the current ETag and an idempotency key. Suppression requires an idempotency key. Treat unknown state values as unknown. To download campaign results and transcripts, use the campaign ID with the campaign evidence exports.