Campaigns API
Create an outbound campaign from a list of phone numbers, start it, pause, resume or cancel it, and read its status.
A campaign calls a list of people with one agent. Create it as a draft, start it when you are ready, and pause, resume or cancel it from your own systems. Calling hours, retries and scripts are set in the dashboard; see Campaigns.
POST /v1/campaigns/{id}/start and /resume start real calls to every waiting number and use your plan's voice minutes. POST /v1/campaigns only creates a draft and calls nobody.Scopes
campaigns:readforGETcampaigns:writefor create, start, pause, resume and cancel
The campaign object
| Field | Type | Notes |
|---|---|---|
id | string (UUID) | Set by Dhvanee. |
name | string | 1 to 200 characters. Surrounding spaces are removed. |
status | string | draft, scheduled, running, paused, completed or cancelled. completed is set by Dhvanee when every number has been tried. |
agent | string (UUID) or null | The agent that makes the calls. |
from | string or null | The workspace number the calls are made from. null when none was chosen. |
recipients | integer | How many phone numbers the campaign holds. Results per number are in the dashboard; this API does not return them. |
{"id": "9fb8784b-2c73-4a0b-b2ff-1b82279832ba", "name": "Teeth whitening offer - January", "status": "draft", "agent": "61e173d2-f4e9-4153-869a-37c7fce1dafc", "from": "+918045678101", "recipients": 24}List campaigns
Newest first, at most 100, with no paging. It shows the campaigns of the dashboard and of this API. Single calls placed with the Calls API and the hidden campaigns of automations are not listed.
curl -sS -X GET "https://api.stage.dhvanee.com/v1/campaigns" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY"{"items": [{"id": "9fb8784b-...", "name": "Teeth whitening offer - January", "status": "scheduled", "agent": "61e173d2-...", "from": "+918045678101", "recipients": 24}]}Create a campaign
curl -sS -X POST "https://api.stage.dhvanee.com/v1/campaigns" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"January follow-ups","agent_id":"AGENT_ID","to":["+919876543210","+919876543211"],"from":"NUMBER_ID"}'| Field | Required | Notes |
|---|---|---|
name | yes | 1 to 200 characters. |
agent_id | yes | An agent of this workspace. Publish it before you start the campaign (Agents API); creating the draft does not check this, but start refuses a conversational-flow agent that was never published. |
to | yes | 1 to 1000 phone numbers. Each is turned into international format using your workspace's country. A number that is not valid is left out without an error, and the same number written twice is kept once; check recipients in the answer. If none is valid the request is refused. |
from | no | The id of a number this workspace owns (Phone numbers API). Without it, calls are made from the oldest number your workspace owns; a workspace with no number cannot start the campaign. |
Returns 201 with the campaign in draft. Nothing is dialed and no minutes are used until you start it. The campaign uses the dashboard's defaults for calling hours (09:00 to 21:00, India time), retries (1) and parallel calls (5); change them in the dashboard before you start.
Read one campaign
curl -sS -X GET "https://api.stage.dhvanee.com/v1/campaigns/CAMPAIGN_ID" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY"Start a campaign
curl -sS -X POST "https://api.stage.dhvanee.com/v1/campaigns/CAMPAIGN_ID/start" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY" \
-H "Idempotency-Key: january-followups-start"- Sets the campaign to
runningand begins dialing the waiting numbers. Returns200with the campaign. - A campaign with no waiting number is refused with
400(Add recipients before starting). - Outside the calling hours the campaign is
runningbut calls wait until the hours open. Idempotency-Keyis required (1 to 128 printable ASCII characters). Repeating the same key for the same campaign returns the first answer and does not start it again. The key is remembered for 24 hours and belongs to the API key that used it.
400 when the dialer cannot place calls for a reason it can tell you: the campaign has no agent (This campaign has no agent selected), its conversational-flow agent was never published (Publish this agent before placing calls. Phone calls run the last published version.), or the workspace has no phone number. The campaign then stays as it was, so fix the cause and start it again.Pause, resume and cancel
curl -sS -X POST "https://api.stage.dhvanee.com/v1/campaigns/CAMPAIGN_ID/pause" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY"curl -sS -X POST "https://api.stage.dhvanee.com/v1/campaigns/CAMPAIGN_ID/resume" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY"curl -sS -X POST "https://api.stage.dhvanee.com/v1/campaigns/CAMPAIGN_ID/cancel" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY"| Action | What happens |
|---|---|
pause | Sets paused. No new number is dialed; calls already ringing or connected are not interrupted. Only a running, scheduled or already paused campaign can be paused (409 Only a running or scheduled campaign can be paused). |
resume | Sets running again and continues with the waiting numbers. Needs the same plan allowance as start (402 otherwise) and can be refused like start (400). A draft is refused with 409 Start the campaign instead of resuming it, a cancelled campaign with 409 A cancelled campaign cannot be resumed. It takes no Idempotency-Key. |
cancel | Sets cancelled and cancels every number that has not been dialed yet. Calls already in progress are not interrupted. It cannot be undone, and cancelling twice is harmless. A completed campaign is refused with 409 A completed campaign cannot be cancelled. |
Each returns 200 with the campaign.
Plan limits and errors
Start and resume need voice minutes, a free call slot and outbound calling on your plan. When one is missing the answer is 402 and the campaign is not started:
{"detail": {"code": "minutes_limit_reached"}}code is one of minutes_limit_reached, wallet_empty, concurrent_limit_reached, outbound_disabled or workspace_inactive. See Credits.
| Status | When |
|---|---|
400 | Start on a campaign with no waiting number (Add recipients before starting). |
401 | No key (Valid API key is required), or an unknown or revoked key (API key is invalid or revoked). |
402 | The plan cannot start calls (detail.code above). |
403 | The key lacks the scope (API key needs campaigns:write scope, or campaigns:read). |
404 | No campaign with that id in this workspace (Campaign not found). |
409 | Start with an Idempotency-Key that was used with a different request (Idempotency-Key was already used with a different request). |
422 | Idempotency-Key is required or Idempotency-Key must be 1-128 printable ASCII characters on start. On create: Unknown workspace agent, Unknown phone number for this workspace (for from), Give at least one valid phone number. Also a missing or malformed field (empty name, to empty or over 1000 entries, an id that is not a UUID). |
429 | Too many requests: detail.code is rate_limit_key, rate_limit_workspace, rate_limit_client or rate_limit_auth_fail. See Rate limits. |
To place a single call without a campaign, see the Calls API. Keys and scopes: Authentication.