Skip to main content
PATCH

Bind an agent to a number

Send inbound_agent_id to have an agent answer the number’s incoming calls, and outbound_agent_id to have it place the calls made from the number when POST /calls names no agent. null unbinds; a field you leave out stays as it is.
Have this agent answer, and call from the number by default
This is the write the workflow editor’s Start sheet makes when you add or remove a number there, so a script and the dashboard change the same row. A number answers with one agent (or two in a split, below): binding another agent takes the number from the first one from the next call, and nothing warns you that it was busy. Publish the agent first: an agent that is inactive or has no published version takes the number’s calls and fails them. Which ways in the agent allows (channels) is a separate setting, in its workflow.

Running two agents on one number

A number can answer — or call — with either of two agents, so you can compare two versions of the same script on real traffic instead of guessing.
Start a test on incoming calls
percent is the share the second agent takes. The agent already bound to the number keeps the rest, so the example above sends 30% of incoming calls to the new agent and 70% to the existing one. Turn it off with { "inbound_split": null } and the number goes straight back to one agent. outbound_split does the same for calls this number places. It applies when POST /calls is sent without an agent_id — an explicit agent_id always wins, and campaigns use their own split, pinned per contact.

What to expect

  • A call never changes sides. Which agent takes a given call is derived from the carrier’s call id, so a redelivered webhook, and every internal check, agree on the same agent.
  • Both agents must be able to take the call. If the second agent is inactive, is an unpublished workflow, or is a different kind of agent from the first, every call goes to the first agent — the test quietly does nothing, and metadata.ab_variant_fallback on the call record says so. Publish the copy before you split traffic to it.
  • Read the results with GET /calls?ab_variant=a and ?ab_variant=b, or from the ab_variant field on each call.
  • BYOC SIP endpoints carry no split. Only purchased numbers do.

What comes back

The number as GET /phone-numbers lists it, rent and next_renewal_at included.

Refusals

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
friendly_name
string | null
inbound_agent_id
string<uuid> | null
outbound_agent_id
string<uuid> | null
inbound_split
object | null

A two-agent A/B test. percent is the share of calls the second agent (agent_id) takes; the resource's existing agent takes 100 - percent.

outbound_split
object | null

A two-agent A/B test. percent is the share of calls the second agent (agent_id) takes; the resource's existing agent takes 100 - percent.

Response

The updated number

id
string<uuid>
number
string
Example:

"+972551234567"

friendly_name
string | null
provider
enum<string>

Where the number comes from: telnyx for a number bought from Yappr, external for a number in your own Telnyx account, added to a carrier account, phone_system for the business number of an extension endpoint that calls out through your own phone system (register.outbound): switched on and off on that endpoint, never released here, no rent, and no calls in (they reach the endpoint's own agent; inbound_agent_id and inbound_split are refused with 422 FIELD_NOT_ALLOWED).

Available options:
telnyx,
external,
phone_system
status
enum<string>
Available options:
active,
pending_requirements,
suspended
is_active
boolean
inbound_agent_id
string<uuid> | null
outbound_agent_id
string<uuid> | null
inbound_split
object | null

The A/B test on incoming calls, or null when the number always answers with inbound_agent_id.

percent is the share of calls that go to the SECOND agent (agent_id below). The agent already bound to the number takes the rest — a percent of 30 means 70% of calls to inbound_agent_id and 30% to the second agent. The dashboard slider shows the first agent's share and stores 100 - slider; the API always states the second agent's.

Which agent answers a given call is fixed for that call: it is derived from the carrier's call id, so a redelivered webhook and every internal re-derivation agree. If the second agent cannot take calls (inactive, an unpublished workflow, or a different kind of agent from the first), the call goes to the first agent and the call record says so.

outbound_split
object | null

The same thing for calls this number places: when POST /calls is sent without an agent_id, this split decides which agent calls. An explicit agent_id always wins. BYOC SIP endpoints carry no split.

sip_inbound_configured
boolean

Whether carrier-side routing for incoming calls is in place. On an external number: whether the number is on Yappr's Call Control App in your Telnyx account, so calls to it reach Yappr.

sip_outbound_configured
boolean
country_code
string | null
monthly_cost
number | null

The number's monthly price in cents, before VAT, as listed for it. Whether Yappr charges it is rent. Null on an external number.

rent
object

Whether Yappr charges the number's monthly rent. Returned by GET /phone-numbers and PATCH /phone-numbers/{id}; not part of a number embedded elsewhere (a campaign's from_phone_number, a carrier account's numbers).

next_renewal_at
string<date-time> | null

When the rent next renews: monthly, on the day and time the subscription started (the last day of a shorter month). Null when rent.included, and when the number's release is scheduled (scheduled_release_at): it does not renew. Returned by GET /phone-numbers and PATCH /phone-numbers/{id}.

scheduled_release_at
string<date-time> | null

When a number released with POST /phone-numbers/{id}/release goes: the end of the period already paid for. Until then the number keeps working as before; POST /phone-numbers/{id}/keep undoes the release. Null when no release is scheduled.

created_at
string<date-time>
phone_system
object | null

The extension endpoint a phone_system number calls out through; null on every other number.

carrier_account
object | null

The Telnyx account an external number calls through. null on numbers bought from Yappr, and for a key without carrier_accounts:read — provider: external still says the number is your own. On a number a disconnect kept for its history, status is disconnected: GET /carrier-accounts/{id} no longer finds the account, and its id is what removes the number (DELETE /carrier-accounts/{id}/numbers/{phone_number_id}).

carrier_state
object | null

Where an external number stands in your Telnyx account. null on numbers bought from Yappr, and for a key without carrier_accounts:read. state is the first of these that applies: telnyx_gone (Telnyx no longer lists it: a sync found it gone, since removed_at; it cannot call), removed (Removed from this workspace: a disconnect kept it for its call history, since removed_at; it may still be in your Telnyx account, it cannot call, and carrier_account.status is disconnected), not_ready (Telnyx lists it with a status other than active), paused (its carrier account is paused), blocked (not configured, and a setting in blockers stops Yappr answering it), not_configured (calls out work; calls in still ring at current_connection_name until you configure it with POST /carrier-accounts/{id}/numbers/{phone_number_id}/configure) and ready (calls to it are answered here).

ownership_verified_at
string<date-time> | null

When your Telnyx API key last proved that this external number is an active number in your account. null means that is not proven now: Telnyx no longer lists it as active, or its account was disconnected. The number is not callable until a test or a sync finds it again. Always null on numbers bought from Yappr.