Skip to main content
POST
Enroll contacts
Adds contacts to a campaign. Enroll leads you already have with lead_ids, raw phone numbers with phone_numbers, or both in one request. Numbers are matched to existing leads where possible and created as new leads otherwise. A key limited to some agents can enroll into its own campaigns the same way. Leads belong to the whole workspace, so a number it sends is matched to the workspace’s lead for that number, or becomes a new workspace lead — this is the one way such a key writes leads. The response is a report, not a failure: bad rows are described rather than aborting the batch, so a list with three unparseable numbers and two people on the do-not-call list still enrolls everybody else and tells you exactly who was skipped and why. Enrollment works on a draft campaign and on a live one — adding contacts to a running campaign is supported and they join the queue at the normal pace. Required scope: campaigns:manage.

Path parameters

Body

At least one of lead_ids / phone_numbers must be present and non-empty. Their combined length may not exceed 1000 per request — send several requests for a longer list. No other field is read, at the top level or in an entry. A field that is not one of these — a misspelt emial, a lead_id for lead_ids — refuses the whole request with 400 CAMPAIGN_REQUEST_INVALID and nothing is enrolled, rather than being dropped (a misspelt email used to enrol the contact with no email and no word). Every such field is named at once in issues[], each with code: "field_unknown", its path, and, when a field it reads is close, the one it was likely meant to be:
Numbers are canonicalized before any lookup or insert, so the same person supplied as 0501234567 in one row and +972501234567 in another resolves to one lead and one enrollment rather than two. name, email and notes apply to newly created leads. When a number matches a lead you already have, the existing lead is enrolled as-is and its details are left untouched — update it through PATCH /leads/{id} if you need to change them.

What gets skipped

A draft holds no number. A campaign that has never been launched dials nobody, so a number sitting on a draft can be enrolled anywhere else. When a draft is launched, any contact whose number another campaign is calling by then is retired as excluded with stop_reason: "in_another_campaign" — visible in GET /campaigns/{id}/leads. A verbal opt-out during a call (“stop calling me”) adds that number to the do-not-call list automatically, workspace-wide, so it will be skipped by every future enrollment as well.

Response fields

Example request

Example response

A request where every entry was skipped before the enrolment step still returns 200 with the report, and without total_leads:
Always inspect the report rather than assuming 200 means everything landed.

Errors

A number another campaign is calling is not an error: it is reported under in_another_campaign and everyone else is enrolled. Earlier versions refused the whole request with 409 ALREADY_IN_ACTIVE_CAMPAIGN; that response is no longer returned. The code arrives in code, and is repeated in error for callers written against the older shape. Branch on code.

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).

Path Parameters

id
string<uuid>
required

Body

application/json

Supply lead_ids, phone_numbers, or both — at least one must be non-empty.

lead_ids
string<uuid>[]

IDs of leads that already exist in this workspace.

phone_numbers
(string | object)[]

Numbers to enroll. Each entry is either a bare phone string or an object. Any format is accepted and normalized to E.164.

Example:

"+972501234567"

Response

Enrollment report. Returned even when nothing was enrolled — read the counters and the rejection arrays to see why.

Result of POST /campaigns/{id}/leads. Enrollment is per-row and best-effort: a bad phone number or a number on the do-not-call list is reported here rather than failing the whole batch, and re-enrolling an existing contact is idempotent.

Numbers are canonicalized to E.164 before anything is written, so the same person cannot be enrolled twice under two formats.

campaign_id
string<uuid>
enrolled
integer

Contacts newly enrolled by this request.

already_enrolled
integer

Contacts that were already enrolled — no-ops, not errors.

leads_created
integer

New leads created from phone_numbers entries with no existing match.

leads_matched
integer

phone_numbers entries matched to a lead you already had. A number an earlier entry of the same request carried is not counted here; see duplicates_in_request.

duplicates_in_request
integer

Entries whose number (or lead) an earlier entry of this same request already carried. Each is one contact with the first: reported in results as already_enrolled at its own row, and never counted as a lead you already had.

invalid_phone
object[]

Rows rejected before enrollment because nobody can dial the number (the POST /leads rule: letters, or an Israeli number of an impossible length or prefix such as 12345), because the number is outside Israel (calls can only be placed to Israeli numbers, +972), or because the lead could not be created. No lead is created for these.

invalid_email
object[]

phone_numbers entries whose email is not an address (the POST /leads rule). The email is never stored; the contact is still enrolled without it (a new lead is created with no email, a matched lead is left as it was), so each entry here also appears in results.

on_do_not_call
string[]

Numbers excluded because they are on the workspace do-not-call list. A phone_numbers entry that matches no lead is screened before a lead is made for it, so a number reported here never becomes a new lead. A verbal opt-out on a call adds the number to that list automatically, workspace-wide, so previously-contacted people can appear here.

not_found
string<uuid>[]

IDs from lead_ids that are not leads in this workspace.

in_another_campaign
object[]

Numbers another live campaign is already calling, each with that campaign. Not enrolled here: a number is dialed by one campaign at a time. A draft holds no number, so a number parked on a draft never appears here.

results
object[]

One entry per number that got past parsing and the do-not-call screen, in the order supplied (lead_ids first, then phone_numbers), each with its row: enrolled, already_enrolled (already on this campaign, or the same number twice in this request) or in_another_campaign (with campaign_id and campaign_name).

total_leads
integer

Total contacts enrolled in the campaign after this request. Present whenever a number reached the enrolment step — including when every one was already enrolled; omitted when every entry was skipped before it (an undiallable number, an unknown lead, the do-not-call list).

company_id
string<uuid>