Skip to main content
POST
Create campaign
A campaign is a paced list of outbound calls over enrolled contacts. You describe who to call, which agent calls them, when to stop calling a person, and how fast the list may be worked; the platform does the rest. A campaign is always created in draft, whatever you send. Nothing is dialed until you call POST /campaigns/{id}/launch, so a draft is a safe place to enroll contacts and tune pacing. There is no separate draft flag to set and no way to create a campaign already running — create, enroll, then launch. Drafts saved from the dashboard’s campaign wizard are these same rows. A draft you create here appears in the dashboard’s campaigns list and can be finished there, and a draft parked in the wizard can be read, patched and launched through this API. Required scope: campaigns:manage.
No configuration field has a default but stop_disposition_ids, which a new campaign fills with the suggested stop set when you leave it out. The “Suggested” column below is what the dashboard prefills for a human, not what the API substitutes for you. Any other field you never send stays null, and POST /campaigns/{id}/launch returns 422 CAMPAIGN_NOT_READY naming it.This is deliberate. How many times to call someone, and how often, are decisions the platform will not quietly make on your behalf. Send every field on create, or fill the gaps with PATCH before you launch.To start from what the dashboard offers, read GET /campaigns/defaults: the suggested settings resolved for your workspace — its own outcome IDs, its timezone and working week — in a shape you can send here as-is.

The full journey

  1. Create the draft — POST /campaigns with a name, the agent_id that will do the talking, optionally the from_phone_number_id to call from (left out, the campaign calls from the agent’s own number), a regulatory_basis, and at least one stop rule. from_phone_number_id can be your phone system’s number (provider: "phone_system"), and the campaign then calls out through your phone system; if its outbound calls pause, the campaign pauses with them (paused_config).
  2. Enroll contacts — POST /campaigns/{id}/leads with lead_ids (leads you already have) and/or phone_numbers (numbers that become leads). Numbers on the do-not-call list are reported and skipped.
  3. Tune it — PATCH /campaigns/{id} for pacing, attempt caps, stop rules, budget. Re-read with GET /campaigns/{id}.
  4. Launch — POST /campaigns/{id}/launch. A preflight runs first and returns 422 CAMPAIGN_NOT_READY with a specific reason when the campaign cannot dial. On success the status becomes running.
  5. Watch it — GET /campaigns/{id}/stats for progress counters and last_tick_result, the machine-readable answer to “why is nothing happening right now”. GET /campaigns/{id}/leads for per-contact state.
  6. Control it — POST /campaigns/{id}/pause, /resume, /stop (terminal), or DELETE /campaigns/{id} to archive.

Testing two agents on one campaign

Give a campaign a second agent and it will run both against the same list.
Split the list 70/30
percent is the share the second agent takes. agent_id keeps the rest, so the example above gives 30% of contacts to the new agent and 70% to the existing one. { "split": null } turns the test off.

What to expect

  • A contact keeps the agent it got. The assignment happens once, the first time that contact is admitted, and every later attempt — every no-answer redial — uses the same agent. A retry is the same conversation continued, not a fresh coin toss, so the comparison stays honest.
  • Changing the share later only moves contacts that have not been dialed yet. Raising percent mid-campaign does not re-assign anyone.
  • Changing an agent, or ending the test, does reach contacts already dialed. An assignment belongs to the test as it is configured now. Send "split": null and every contact goes back to the campaign’s own agent on its next attempt; replace either agent and the contacts held by the one you removed are assigned again across the pair you are running now. Only the two agents a campaign is currently running ever place its calls.
  • Both agents have to be launchable. Both need a maximum call duration, and the second one has to be able to take calls; otherwise POST /campaigns/{id}/launch refuses and says which agent is the problem.
  • Switching an agent off is not how you end the test. If an agent that contacts are already pinned to can no longer take calls, those contacts are dialed by the campaign’s own agent instead — the same fallback a phone number makes — and those calls are recorded as version A, because that is who called. The assignment itself is kept, so switching the agent back on returns its contacts to it. To end the test, send "split": null.
  • Both agents are screened against your do-not-call list at enrolment. A contact suppressed for either agent is reported as on_do_not_call and never enrolled, so a contact can never be assigned an agent that is not allowed to call it.
  • Read the results with GET /calls?ab_variant=a and ?ab_variant=b.

Refusals

A campaign call is an ordinary outbound call

A campaign hands calls to the same outbound queue that POST /calls uses, at the same weight. The pacing fields below control how fast a campaign offers calls to that queue — they never buy priority over anything else in the workspace and they cannot raise your concurrency. If the queue is busy, a campaign waits its turn like any other call. Dialing is also gated by your workspace calling hours (GET /call-windows) and by your credit balance, both re-checked continuously while the campaign runs.

Identity and targeting

Stop rules — when to stop calling one person

Two independent per-contact stop conditions apply, whichever fires first:
  • max_attempts — the attempt cap.
  • The stop-disposition set — landing one of these outcomes retires that contact permanently. Anything else is retried until the cap.
At least one of stop_disposition_ids, stop_on_no_answer or stop_on_voicemail must be set before launch. A campaign with no stop rule would call every contact until the attempt cap, so the preflight refuses it. To stop calling people you have already spoken to, create a disposition for that outcome (POST /dispositions) and put its ID in stop_disposition_ids. There is no built-in “reached a human” rule: what counts as a real conversation differs per workspace, so it belongs in your own outcome list where you can see and change it. Interested is a stop like any outcome you name: its ID is accepted, and a new campaign stops on it unless you leave it out. A contact who ends on it is not called again — they show on the campaign’s leads (GET /campaigns/{id}/leads) as completed_success with that outcome, and a follow-up on the agent can notify you. No Answer, Failed, Voicemail and Unclassified are refused in stop_disposition_ids (400, naming the outcome and the switch to use). The platform assigns them by itself — No Answer on every unanswered ring, Failed on every dial that did not go through, and Voicemail or Unclassified even on a call someone answered — so listing one retires the contact the first time it lands, before any retry. Use the stop_on_no_answer / stop_on_voicemail / stop_on_unclassified booleans instead: they are evaluated on the call outcome rather than on the label. Categorization happens after a call ends, not during it, so a contact sits in awaiting_disposition until its outcome lands. It is never re-dialed while in that state, and there is no deadline after which the platform decides without one.
A call’s outcome is authoritative, and a contact is never advanced without one. Outcomes are assigned asynchronously after a call ends, so a contact sits in awaiting_disposition until its outcome arrives — however long that takes. Only that contact waits; the pacer keeps admitting every other contact in the campaign. There is no timeout that decides on your behalf, because “we never learned what happened” is not a basis for calling someone again.

Attempts and retries

Pacing

Money and schedule

budget_cents is this campaign’s lifetime budget: one number, spent down once, never reset. It is not the workspace’s monthly spending limit (monthly_budget_cents, see PATCH /billing), which covers every outbound call in the workspace and lifts by itself at the start of each calendar month. Both can stop this campaign, and both report the same paused_budget status; pause_reason on the campaign says which — campaign_budget or workspace_spend_limit.

Fields you cannot set

Unknown keys are rejected with 400 rather than ignored, so a typo like stop_dispositions can never leave you believing you configured a kill switch that is not there. retry_rules is rejected too. It was an earlier structured retry matrix that the dialer never evaluated; the scalar fields above are the whole retry configuration. These are engine-owned and rejected the same way: status, from_number, daily_admitted_count, daily_window_date, last_admitted_at, spent_cents, reserved_cents, estimate_cents, last_tick_at, last_tick_result, last_error, started_at, completed_at, total_leads, stats.

Example request

Example response

HTTP 201. agent, from_phone_number and stop_dispositions expand the IDs you supplied — each is the complete referenced object, abbreviated here for brevity.

Errors

Every CAMPAIGN_REQUEST_INVALID above names all the problems in the body at once: issues[] carries one {code, path, message} per field at fault — /max_attempts, /calling_window/days, /calling_window/start, each platform outcome at /stop_disposition_ids/<n> (platform_stop_outcome), the number (invalid_from_number) and the agents (agent_not_found) — and error is the first of them with a count of the rest. ["No Answer", "Voicemail"] beside max_attempts: 0 is three issues in one answer.

Authorizations

Authorization
string
header
required

Your Yappr API key (e.g. ypr_live_...). Generate one in the dashboard under Settings → API Keys. No key is 401 MISSING_KEY; a key that is not one of ours, or is revoked, is 401 INVALID_KEY; an expired one is 401 EXPIRED_KEY. A valid key without the scope an operation needs is 403 INSUFFICIENT_SCOPE on every operation, and the message names the scope. Every response, a 401 included, carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset: the budget is 60 requests a minute per API key. Every 429, whatever its code, carries Retry-After (whole seconds, never zero): the per-key budget's RATE_LIMIT asks for what is left of the minute, a route's daily cap (RATE_LIMITED) for the time until that cap resets. All four headers are listed in Access-Control-Expose-Headers, so a browser can read them. A path the API does not serve (an unknown sub-path, an id left empty) is 404 ROUTE_NOT_FOUND, and a method a served path does not take is 405 METHOD_NOT_ALLOWED with an Allow header; both are answered before any scope check, and nothing is read or changed. A trailing slash is ignored where it cannot be an id left empty (POST /calls/ is POST /calls) and refused where it can (GET /calls/). A doubled slash inside a path is merged into one before the request reaches the API (GET //calls is GET /calls).

Body

application/json
name
string
required
Example:

"July reactivation"

description
string | null
agent_id
string<uuid>

Required before launch.

from_phone_number_id
string<uuid> | null

The number to call from. Leave it out to call from the agent's own number (from_number in the answer says which); 400 with invalid_from_number when the agent has no number and none is sent.

split
object | null

Optional two-agent A/B test. percent is the share of contacts the SECOND agent takes; agent_id above takes the rest. Send null to turn it off. 422 INVALID_SPLIT when the object has a key other than those two, the percent is outside 1–99, or the second agent is the same as agent_id. An agent that is not in this workspace is 404 AGENT_NOT_FOUND.

variables
object

Values for the agent's {{placeholders}} on every call this campaign places. FirstName and FullName are filled on each call from its contact's own name; the value here is what a contact with no name hears. String values only; the automatically filled names (CallerPhone, CurrentDate, CurrentDateTime, CurrentTime, CallDirection, Timezone) are refused.

calling_window
object

Optional narrowing of the workspace calling hours. Cannot widen them. tz (an IANA zone name) is required whenever days, start or end is present; {} inherits the workspace schedule. days 0–6, each once, never empty; start/end as HH:MM, together, end later than start.

stop_disposition_ids
string<uuid>[]

Disposition IDs (never labels) that retire a contact permanently. Interested is accepted like any outcome you name. Do not include No Answer, Failed, Voicemail or Unclassified (refused) — use stop_on_no_answer / stop_on_voicemail / stop_on_unclassified instead. Left out, the campaign stops on the set GET /campaigns/defaults returns (Interested and the workspace's own outcomes included); [] for none.

stop_on_no_answer
boolean
Example:

false

stop_on_voicemail
boolean
Example:

false

stop_on_unclassified
boolean
Example:

false

max_attempts
integer
Required range: 1 <= x <= 999
Example:

3

max_infra_retries
integer
Required range: 0 <= x <= 20
Example:

3

retry_no_answer_seconds
integer
Required range: 30 <= x <= 604800
Example:

3600

retry_completed_seconds
integer
Required range: 60 <= x <= 604800
Example:

86400

randomize_retry_time
boolean

false keeps a retry at the same time of day; true picks another hour inside the calling window.

Example:

false

double_dial_enabled
boolean
Example:

false

double_dial_gap_seconds
integer
Required range: 10 <= x <= 3600
Example:

90

max_calls_per_day
integer
Required range: 1 <= x <= 100000
Example:

200

min_seconds_between_calls
integer
Required range: 0 <= x <= 86400
Example:

30

max_in_flight
integer
Required range: 1 <= x <= 8
Example:

2

budget_cents
integer | null

Hard spend cap in credits (a credit is a cent). At least one call's hold once the campaign has an agent. Null for no cap.

Required range: x >= 1
regulatory_basis
enum<string>

Required before launch.

Available options:
lawful_basis_confirmed,
consent,
existing_customer,
non_marketing,
registry_screened
starts_at
string<date-time> | null
ends_at
string<date-time> | null

Response

Campaign created in draft

A paced bulk-outbound dialing job over enrolled contacts.

A campaign is an admission-only scheduler. It decides when each enrolled contact becomes eligible, then performs one ordinary outbound call — the same queue, the same priority, and the same concurrency limits as a call placed with POST /calls. The pacing fields below only control how fast a campaign hands calls to that queue; a campaign call never takes precedence over anything else.

Campaigns are always created as draft and are launched with POST /campaigns/{id}/launch.

Two independent per-contact stop conditions apply, whichever fires first: max_attempts, and the stop-disposition set (stop_disposition_ids plus the stop_on_* booleans). Landing a stop disposition retires that contact permanently; any other outcome retries until the attempt cap.

Fields marked Engine-owned are written by the campaign engine and are never writable. Sending one on create or update returns 400, as does any field name that isn't on the writable list — a misspelled stop_dispositions is rejected rather than silently ignored, so you can never believe a kill switch is armed when it is not.

id
string<uuid>
company_id
string<uuid>
name
string
Example:

"July reactivation"

description
string | null
status
enum<string>

Engine-owned. Move it with the transition endpoints (launch / pause / resume / stop), never with PATCH.

draft — created, not dialing. scheduled — not entered today. A campaign launched before its starts_at reads running and places no call until that moment. running — admitting contacts. paused — paused by you. A manual pause is never lifted automatically; it survives a top-up. paused_insufficient_credit — balance is below the minimum needed to place a call. Auto-resumes shortly after the balance is topped up. paused_budget — budget_cents reached, or the workspace's own monthly spending limit reached; pause_reason says which. paused_infra — the safeguard: one contact's call could not be placed more times than max_infra_retries allows (nobody's phone rang). Calls already under way finish normally and every contact keeps its place; nothing new is dialed until you resume. Not lifted automatically. paused_config — a permanent configuration problem (from-number no longer active, agent missing a call-duration cap, no reachable calling window). completed — every enrolled contact reached a terminal state. stopped — stopped by you. Terminal. archived — soft-deleted by DELETE /campaigns/{id}. Terminal.

Available options:
draft,
scheduled,
running,
paused,
paused_insufficient_credit,
paused_budget,
paused_infra,
paused_config,
completed,
stopped,
archived
pause_reason
enum<string> | null

Why the campaign is paused, or null when it is not. Read-only. manual (paused), insufficient_credit (paused_insufficient_credit), campaign_budget or workspace_spend_limit (both paused_budget — this campaign's budget_cents, or the workspace's monthly limit from PATCH /billing), call_placement_failures (paused_infra), configuration (paused_config).

Available options:
manual,
insufficient_credit,
campaign_budget,
workspace_spend_limit,
call_placement_failures,
configuration,
null
agent_id
string<uuid> | null

Agent that runs the calls. Required before launch.

agent
object | null

The Agent for agent_id. For a key holding agents:read it is the same object, field for field, that GET /agents/{id} returns for it. For a key without agents:read it is { id, name } only: the campaign never shows a key more of an agent than GET /agents/{id} would.

split
object | null

The A/B test on this campaign's calls, or null when every contact is called by agent_id.

percent is the share of contacts that go to the SECOND agent (agent_id inside the object). agent_id on the campaign takes the rest.

A contact is assigned once, on its first admission, and keeps that agent for every later attempt — a no-answer redial is the same conversation and not a fresh coin toss. Changing percent afterwards therefore only affects contacts that have not been dialed yet. Changing either agent, or sending null, does reach contacts already dialed: an assignment to an agent the campaign no longer runs is released, and that contact is assigned again on its next attempt. Both agents must have a maximum call duration set and be able to take calls, or launch refuses.

Both agents are screened against the do-not-call list at enrolment, so a contact is never assigned an agent that is not allowed to call it.

split_agent
object | null

The Agent for the second agent in split, read like agent: the object GET /agents/{id} returns for a key holding agents:read, { id, name } for a key without it.

from_phone_number_id
string<uuid> | null

The number the campaign calls from, when it names one. null (the default) calls from the agent's own number: a number the agent calls from (its outbound agent, or either half of the number's outbound split), else one it answers on; a Yappr number before one on your own Telnyx account. An A/B split calls from the first agent's number for both halves. A create or edit that leaves it null on an agent with no number is 400 CAMPAIGN_REQUEST_INVALID (invalid_from_number at /from_phone_number_id); at launch the number must still be active. If this number is released, the campaign calls from its agent's own number from then on.

from_phone_number
object | null

The PhoneNumber for from_phone_number_id. For a key holding phone_numbers:search it is exactly the object GET /phone-numbers returns, and only that. For a key without it, it is { id, friendly_name, number: null }: which number, and what it costs, are that scope's to show (friendly_name is null too when it spells the number). The carrier account's own plumbing (provider and order ids, SIP trunk/credential identifiers, SIP usernames and secrets) is never part of it.

from_number
string | null

Engine-owned. E.164 number the campaign calls from: from_phone_number's, or its agent's own number when from_phone_number_id is null. Written on create, edit and launch, and on every dialling round, so it follows the agent onto a new number; kept for audit even if the number is later released. null until the campaign has an agent or a number that can call, and for a key without phone_numbers:search, as from_phone_number.number is.

Example:

"+972551234567"

variables
object

Values for the agent's {{placeholders}} on every call this campaign places. FirstName and FullName are filled on each call from its contact's own name (the first word of it, and the whole of it; a household, a title or half of a given name keeps the whole name under FirstName: "משפחת כהן"); the value here is what a contact with no name hears. {} when none are set.

calling_window
object

Optional campaign-level narrowing of the workspace calling hours. Omit to inherit the workspace schedule (GET /call-windows). A campaign can only ever dial inside the workspace window — this field cannot widen it. { tz, days: [0..6], start: "HH:MM", end: "HH:MM" }. tz is an IANA zone name and is required whenever days, start or end is present: hours without a zone are ambiguous, so they are refused rather than read against a zone you did not pick. days lists each day once and is never empty; start and end come together and end is later than start (no zero-minute window, none past midnight). Anything else is 400 CAMPAIGN_REQUEST_INVALID, naming the value.

stop_disposition_ids
string<uuid>[]

Disposition IDs that retire a contact permanently when assigned — the campaign's kill switch. Always IDs, never labels: labels are renameable, and a rename would silently disarm the rule.

No Answer, Failed, Voicemail and Unclassified are refused here with 400. The platform assigns them by itself (No Answer on every unanswered ring), so listing one retires the contact the first time it lands, before any retry, and Voicemail or Unclassified can land on a call someone answered. Use stop_on_no_answer, stop_on_voicemail and stop_on_unclassified instead.

Must contain dispositions belonging to your company; anything else is rejected with 400.

stop_dispositions
object[]

Full Disposition objects for stop_disposition_ids.

stop_on_no_answer
boolean

Retire a contact the first time a call goes unanswered.

Example:

false

stop_on_voicemail
boolean

Retire a contact the first time a call reaches an answering machine.

Example:

false

stop_on_unclassified
boolean

What to do when the outcome that arrives is Unclassified — the call happened but could not be matched to any of your outcomes. false retries the contact, true retires it. This is not a timeout. A call's outcome is authoritative and a contact is never advanced without one: if classification is slow, only that contact waits while the campaign keeps calling everyone else.

Example:

false

max_attempts
integer

Per-contact dial cap. One of the two independent stop conditions — the other is the stop-disposition set.

Required range: 1 <= x <= 999
Example:

3

max_infra_retries
integer

The safeguard: how many retries one contact gets after a platform-side failure — a call that never reached the person — before the whole campaign pauses as paused_infra. A count, not money: the money limits are budget_cents and the workspace's monthly spending limit. These retries do not consume max_attempts and are never terminal.

Required range: 0 <= x <= 20
Example:

3

retry_no_answer_seconds
integer

Delay before retrying a contact who did not answer.

Required range: 30 <= x <= 604800
Example:

3600

retry_completed_seconds
integer

Delay before retrying a contact whose call completed but landed on a non-stop disposition.

Required range: 60 <= x <= 604800
Example:

86400

randomize_retry_time
boolean

Which time of day a retry lands on. false keeps the wait exact, so a one-week wait retries at the same hour a week later. true picks a different hour inside the campaign's calling window, so repeat attempts do not always arrive at the same moment. The wait length itself is unchanged either way — a randomized retry is still never earlier than the configured wait.

Example:

false

double_dial_enabled
boolean

Ring a second time shortly after an unanswered first ring.

Example:

false

double_dial_gap_seconds
integer

Gap between the two rings when double_dial_enabled is true.

Required range: 10 <= x <= 3600
Example:

90

max_calls_per_day
integer

Daily admission cap, counted against the workspace timezone day.

Required range: 1 <= x <= 100000
Example:

200

min_seconds_between_calls
integer

Minimum spacing between two calls handed to the queue by this campaign.

Required range: 0 <= x <= 86400
Example:

30

max_in_flight
integer

Calls this campaign may have live at once. Platform concurrency limits still apply on top — raising this does not buy the campaign extra capacity.

Required range: 1 <= x <= 8
Example:

2

budget_cents
integer | null

This campaign's LIFETIME spend cap, enforced against spent_cents + reserved_cents (credits are debited when a call ends, so in-flight cost has to count) plus the next call's hold: twice the agent's max_call_duration_secs, in minutes, times the per-minute rate (the highest per-minute price of any voice model, as GET /billing/rates lists them). Counted in credits: a credit is one cent. A cap below one call's hold is refused with 400 (it would pause the campaign before its first call), and launch refuses one stored before that check. null means no cap. On hit the campaign moves to paused_budget. Distinct from the workspace's calendar-month limit (monthly_budget_cents, PATCH /billing), which covers every outbound call in the workspace and resets each month: either can pause this campaign and both report paused_budget.

Required range: x >= 1
regulatory_basis
enum<string> | null

Your lawful basis for calling this list. Required before launch — recorded on the campaign's launch audit record alongside the enrolled count. lawful_basis_confirmed is what the dashboard records: a single attestation that the caller has consent or another lawful basis for everyone on the list. The four specific values are for callers that know which one applies.

Available options:
lawful_basis_confirmed,
consent,
existing_customer,
non_marketing,
registry_screened
starts_at
string<date-time> | null

No call is placed before this moment. It does not launch the campaign: a campaign launched earlier reads running and waits.

ends_at
string<date-time> | null

No new call is placed from this moment; the campaign then moves to completed. Later than starts_at, not already passed, and the calling_window must open at least once before it.

daily_admitted_count
integer

Engine-owned. Calls handed to the queue during the current day window.

daily_window_date
string<date> | null

Engine-owned. Day daily_admitted_count belongs to.

last_admitted_at
string<date-time> | null

Engine-owned. When this campaign last handed a call to the queue.

estimate_cents
integer | null

Engine-owned. Reserved for a projected campaign cost; nothing computes it yet, so it is null.

spent_cents
integer

Engine-owned. Settled spend so far.

reserved_cents
integer

Engine-owned. Worst-case cost of in-flight calls, held against budget_cents until they settle.

last_tick_at
string<date-time> | null

Engine-owned. Last time the engine evaluated this campaign.

last_tick_result
string | null

Engine-owned. Machine-readable answer to "why is nothing happening right now" — e.g. daily cap reached, outside the calling window, waiting on in-flight calls. blocked means another operation held this campaign during the last evaluation and it is retried on the next one. Full vocabulary on the campaign stats page.

last_error
string | null

Engine-owned. Last error the engine recorded for this campaign.

started_at
string<date-time> | null

Engine-owned. First launch time.

completed_at
string<date-time> | null

Engine-owned. When the last contact reached a terminal state.

total_leads
integer

Engine-owned. Contacts currently enrolled.

stats
object

Engine-owned counter roll-up. Prefer GET /campaigns/{id}/stats.

created_at
string<date-time>
updated_at
string<date-time>
created_by
string<uuid> | null

Null when the campaign was created via the API.