Bulk calls API
Bulk calls: one message or assistant calling a list of people.
The same operations are in the interactive API reference, and the whole contract is in the OpenAPI document.
GET/v1/campaigns
List campaigns
Returns every campaign in the organization, newest first, in the same envelope as other lists.
Needs campaigns:read. Test keys see the sandbox organization's campaigns, live keys the real ones; the two never mix.
Paged, newest first: limit is 1 to 100 (default 50, out of range values are clamped) and cursor is the next_cursor of the previous page. The cursor is opaque and never built by the client; a cursor this API did not return is a 400. has_more is true while another page exists. There is no total. Only bulk campaigns are listed.
Scope campaigns:read. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | No | How many items to return. Default 50, at most 100. |
cursor | query | string | No | The `next_cursor` of the previous page. Opaque; never built by the client. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
POST/v1/campaigns
Create a campaign
Creates a campaign in draft. A draft costs nothing and calls nobody. Next, set what it says with PUT /v1/campaigns/{id}/message, add people with POST /v1/campaigns/{id}/audience, then launch it.
Only organization admins may run bulk calls; a member or a restricted key without campaigns:write gets 403. Bulk calls cost money per minute, which is why creating one is admin-only even though nothing is spent yet.
Only name is required. The call window defaults to 09:00:00 to 19:00:00 in Asia/Kathmandu. A message campaign (delivery: message) says one fixed message and ends; it must carry a message, otherwise the request is refused with 400. An ai campaign (the default) holds a conversation guided by agenda and, optionally, a published form whose questions every call asks.
Works the same with a test key: the draft lands in the sandbox. Costs nothing in either mode. Send Idempotency-Key so a retry returns the first result. Without one, a repeated request can create a second draft.
Scope campaigns:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Makes a POST safe to repeat: the same key returns the first result for 24 hours. The same key with a different body is refused with `422 idempotency_key_reused`; while the first request still runs, `409 idempotency_in_progress`. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
GET/v1/campaigns/{id}
Get a campaign
Returns one campaign with its settings, call window and current status. Needs campaigns:read.
The status moves draft, scheduled, running, paused, then completed or cancelled. Use GET /v1/campaigns/{id}/stats for progress and /results for individual people. A campaign from another organization, or from the other mode, is 404, never 403.
Scope campaigns:read. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
PUT/v1/campaigns/{id}/message
Set what the campaign says
Sets what the campaign says: AI instructions or a recording, the goals of the call and the form to fill in. The message replaces the earlier one in full, so send everything you want kept.
Only organization admins may run bulk calls; a member or a restricted key without campaigns:write gets 403.
The message is reviewed automatically. The result comes back in review, and launch is refused until the message is approved, so read review before launching. A message the review blocks does not fail this call; it is saved and shows its verdict.
Idempotent by nature: sending the same body twice leaves the same message. Costs nothing.
Scope campaigns:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
POST/v1/campaigns/{id}/audience
Add people to the campaign
Adds people to the campaign. Contacts, contact groups, pasted phone numbers and brand-new contacts can be mixed in one request, and the request can be repeated to add more.
Only organization admins may run bulk calls; a member or a restricted key without campaigns:write gets 403.
This returns 202 with a job, not the finished audience. The job resolves groups, normalizes numbers, drops duplicates and skips do-not-call numbers in the background (it can take minutes for large lists, and is retried once on a database failure). Poll GET /v1/campaigns/{id}/stats to watch total_contacts grow. The job object is a generic background job record and is not described further here.
Groups named here are remembered on the campaign. With follow_groups: true, people who join those groups later are added until the campaign ends.
Send Idempotency-Key: it is passed to the job queue, so a retry with the same key does not enqueue a second job. Costs nothing by itself; the cost comes when the calls are placed.
Scope campaigns:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
Idempotency-Key | header | string | No | Makes a POST safe to repeat: the same key returns the first result for 24 hours. The same key with a different body is refused with `422 idempotency_key_reused`; while the first request still runs, `409 idempotency_in_progress`. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
POST/v1/campaigns/{id}/launch
Launch a campaign
Starts the calls, or schedules the start when starts_at is in the future. The body is optional; with no body the campaign starts now.
Only organization admins may run bulk calls; a member or a restricted key without campaigns:write gets 403. A test key cannot launch: it is refused with 403, because a test key never dials real numbers. Use a live key.
Launch checks, in order: the account has the campaigns capability unlocked; the message exists and is approved; the content passes screening; and the organization has added credit. Free credit does not pay for bulk calls, so an account with only free credit gets 402 with the shortfall in the message. If the campaign has no number of its own and no sender pool, it calls from AirFone's shared numbers when the organization has no outbound number of its own.
Launching a campaign that is already running or scheduled is not an error: it returns that state with already: true, so a double tap is safe. A starts_at in the past is treated as now. The schedule is only recorded for a draft or paused campaign.
Send Idempotency-Key as well. Calls placed are charged per minute from the wallet as they happen.
Scope campaigns:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
Idempotency-Key | header | string | No | Makes a POST safe to repeat: the same key returns the first result for 24 hours. The same key with a different body is refused with `422 idempotency_key_reused`; while the first request still runs, `409 idempotency_in_progress`. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
POST/v1/campaigns/{id}/pause
Pause a campaign
Stops new calls from starting. Calls already in progress finish normally; nobody is hung up on. Launch again to resume where it left off.
Only organization admins may run bulk calls; a member or a restricted key without campaigns:write gets 403. Only a running campaign can be paused; any other status is refused with 400 (cannot move a campaign from paused to paused; the handler uses 400 for a wrong state, not 409). Pausing twice is therefore an error the second time, not a no-op. Costs nothing; calls in progress are still charged.
Scope campaigns:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
Idempotency-Key | header | string | No | Makes a POST safe to repeat: the same key returns the first result for 24 hours. The same key with a different body is refused with `422 idempotency_key_reused`; while the first request still runs, `409 idempotency_in_progress`. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
POST/v1/campaigns/{id}/cancel
Cancel a campaign
Stops the campaign. Calls in progress finish, and no more are started. Use pause if you may want to continue.
Only organization admins may run bulk calls; a member or a restricted key without campaigns:write gets 403. A draft, scheduled, running or paused campaign can be cancelled; a campaign that is already completed or cancelled is refused with 400, as for pause. People who were not yet called stay unreached.
Cancelling is meant to be final, but note that the launch operation does accept a cancelled campaign and would start it again. Do not rely on a cancelled campaign staying cancelled if another admin has a live key.
Scope campaigns:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
Idempotency-Key | header | string | No | Makes a POST safe to repeat: the same key returns the first result for 24 hours. The same key with a different body is refused with `422 idempotency_key_reused`; while the first request still runs, `409 idempotency_in_progress`. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
GET/v1/campaigns/{id}/stats
Campaign totals
Returns the running totals for one campaign: how many people are on the list and how many are waiting, being dialed, in a call, done, skipped (suppressed) or given up on (exhausted), plus the number of attempts made and calls answered. Needs campaigns:read.
The counts are read live and may change between two requests while the campaign is running. For individual people use GET /v1/campaigns/{id}/results.
Scope campaigns:read. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
GET/v1/campaigns/{id}/results
Per-recipient results
Lists each person on the campaign with the state of their call, the number of attempts and the outcome, newest added first. Needs campaigns:read.
Filter with state. Paged, newest first: limit is 1 to 100 (default 50, out of range values are clamped) and cursor is the next_cursor of the previous page. The cursor is opaque and never built by the client; a cursor this API did not return is a 400. has_more is true while another page exists. There is no total.
has_more is exact: the last page is never followed by an empty one.
Scope campaigns:read. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
state | query | string | No | Only people in this state: `pending`, `dialing`, `in_progress`, `done`, `suppressed` or `exhausted`. |
limit | query | integer | No | How many items to return. Default 50, at most 100. |
cursor | query | string | No | The `next_cursor` of the previous page. Opaque; never built by the client. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |