> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goyappr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Number

> Update one number's agent bindings, its friendly name, and its A/B
tests. Send `inbound_split` / `outbound_split` as
`{ "agent_id": "...", "percent": 30 }` to run two agents on that
direction, or `null` to go back to one.

`percent` is the share the SECOND agent takes. Both agents must belong
to your workspace and must differ from the agent already bound to that
direction.


## 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`](https://docs.goyappr.com/api-reference/calls/create) names no agent. `null` unbinds; a
field you leave out stays as it is.

```json Have this agent answer, and call from the number by default theme={null}
{ "inbound_agent_id": "6f1b2c3d-...", "outbound_agent_id": "6f1b2c3d-..." }
```

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](https://docs.goyappr.com/api-reference/workflows/save.md).

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

```json Start a test on incoming calls theme={null}
{ "inbound_split": { "agent_id": "6f1b2c3d-...", "percent": 30 } }
```

**`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`](https://docs.goyappr.com/api-reference/phone-numbers/list) lists it,
`rent` and `next_renewal_at` included.

### Refusals

| Status | When |
| - | - |
| `404` | No such number in this workspace |
| `422 INVALID_SPLIT` | `percent` outside 1–99, or the second agent is the one already answering. |
| `404 AGENT_NOT_FOUND` | One of the four agent fields — `inbound_agent_id`, `outbound_agent_id`, or a split's `agent_id` — is not an agent in this workspace: it does not exist, belongs to another workspace, or has been archived. The message names which. It used to be `422 INVALID_AGENT`. |
| `422 INVALID_SPLIT` | `inbound_split` / `outbound_split` sent as anything other than an object or `null`, or carrying a key that is not `agent_id` / `percent` |
| `400` | A field this endpoint does not update, or a number still pending regulatory approval |
| `500` | The number, or whether its rent is charged, could not be read. Retry; nothing was written. |


## OpenAPI

````yaml PATCH /phone-numbers/{id}
openapi: 3.1.0
info:
  title: Yappr API
  description: >
    Create and manage AI voice agents, purchase phone numbers, configure tools,
    and initiate calls — all via REST.
  version: 1.0.0
  contact:
    url: https://goyappr.com
servers:
  - url: https://api.goyappr.com
    description: Production
security:
  - apiKey: []
paths:
  /phone-numbers/{id}:
    patch:
      tags:
        - Phone Numbers
      summary: Update number
      description: |
        Update one number's agent bindings, its friendly name, and its A/B
        tests. Send `inbound_split` / `outbound_split` as
        `{ "agent_id": "...", "percent": 30 }` to run two agents on that
        direction, or `null` to go back to one.

        `percent` is the share the SECOND agent takes. Both agents must belong
        to your workspace and must differ from the agent already bound to that
        direction.
      operationId: updatePhoneNumber
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                friendly_name:
                  type: string
                  nullable: true
                inbound_agent_id:
                  type: string
                  format: uuid
                  nullable: true
                outbound_agent_id:
                  type: string
                  format: uuid
                  nullable: true
                inbound_split:
                  nullable: true
                  allOf:
                    - $ref: '#/components/schemas/AgentSplit'
                outbound_split:
                  nullable: true
                  allOf:
                    - $ref: '#/components/schemas/AgentSplit'
              additionalProperties: false
            examples:
              start_a_test:
                summary: Send 30% of incoming calls to a second agent
                value:
                  inbound_split:
                    agent_id: 6f1b...
                    percent: 30
              stop_a_test:
                summary: Go back to one agent
                value:
                  inbound_split: null
      responses:
        '200':
          description: The updated number
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PhoneNumber'
        '404':
          description: No such number in this workspace
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >
            `INVALID_SPLIT` — the split is not an object or `null`, carries a
            key

            other than `agent_id` / `percent`, the share is outside 1–99, the
            second

            agent is the one already answering. The message says which. An agent

            field that names no agent in this workspace is 404
            `AGENT_NOT_FOUND`,

            naming the field.

            A number from your own Telnyx account (`provider: external`) takes
            an

            `inbound_agent_id` and an `inbound_split` like any other; the agent

            answers once the number is configured (`carrier_state.state` is

            `ready`). `INBOUND_NOT_AVAILABLE_ON_EXTERNAL_NUMBER` is retired.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AgentSplit:
      type: object
      description: |
        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`.
      properties:
        agent_id:
          type: string
          format: uuid
          description: The second agent — the one being tested against the existing one.
        percent:
          type: integer
          minimum: 1
          maximum: 99
          description: Share of calls routed to `agent_id`, 1–99.
      required:
        - agent_id
        - percent
    PhoneNumber:
      type: object
      properties:
        id:
          type: string
          format: uuid
        number:
          type: string
          example: '+972551234567'
        friendly_name:
          type: string
          nullable: true
        provider:
          type: string
          description: >
            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](/api-reference/carrier-accounts/add-number),
            `phone_system`

            for the business number of an extension endpoint that calls out
            through your own

            phone system
            ([register.outbound](/concepts/sip-trunks#outbound-calls-through-the-extension)):

            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`).
          enum:
            - telnyx
            - external
            - phone_system
        status:
          type: string
          enum:
            - active
            - pending_requirements
            - suspended
        is_active:
          type: boolean
        inbound_agent_id:
          type: string
          format: uuid
          nullable: true
        outbound_agent_id:
          type: string
          format: uuid
          nullable: true
        inbound_split:
          nullable: true
          description: |
            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.
          allOf:
            - $ref: '#/components/schemas/AgentSplit'
        outbound_split:
          nullable: true
          description: |
            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.
          allOf:
            - $ref: '#/components/schemas/AgentSplit'
        sip_inbound_configured:
          type: boolean
          description: |
            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:
          type: boolean
        country_code:
          type: string
          nullable: true
        monthly_cost:
          type: number
          nullable: true
          description: >
            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:
          description: >
            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).
          allOf:
            - $ref: '#/components/schemas/PhoneNumberRent'
        next_renewal_at:
          type: string
          format: date-time
          nullable: true
          description: >
            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:
          type: string
          format: date-time
          nullable: true
          description: >
            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:
          type: string
          format: date-time
        phone_system:
          type: object
          nullable: true
          description: >
            The extension endpoint a `phone_system` number calls out through;
            `null` on every

            other number.
          properties:
            sip_endpoint_id:
              type: string
              format: uuid
            sip_endpoint_name:
              type:
                - string
                - 'null'
        carrier_account:
          type: object
          nullable: true
          description: >
            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](/api-reference/carrier-accounts/delete) 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}`).
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
            provider:
              type: string
              enum:
                - telnyx
            status:
              type: string
              enum:
                - untested
                - active
                - paused
                - disconnected
        carrier_state:
          type: object
          nullable: true
          description: >
            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).
          properties:
            state:
              type: string
              enum:
                - ready
                - not_configured
                - blocked
                - paused
                - not_ready
                - telnyx_gone
                - removed
            telnyx_status:
              type: string
              nullable: true
              description: >-
                The number's status in Telnyx, as of the last sync. `null` until
                a sync has read it.
            current_connection_name:
              type: string
              nullable: true
              description: >-
                The connection the number is on in Telnyx, as of the last sync.
                `null` when it is on none.
            previous_connection_name:
              type: string
              nullable: true
              description: >-
                The connection the number goes back to when you stop answering
                it here. `null` when it had none.
            blockers:
              type: array
              items:
                type: string
                enum:
                  - forwarding_always
                  - translated_number
                  - tech_prefix
              description: >
                Telnyx settings that stop Yappr answering the number. Configure
                is refused while any is on.

                `forwarding_always`: Telnyx forwards every call to it elsewhere.
                `translated_number`: Telnyx

                delivers its calls as another number. `tech_prefix`: Telnyx adds
                a tech prefix to the dialled

                number, so Yappr could not match it. Change the setting in
                Telnyx, then sync.
            notes:
              type: array
              items:
                type: string
                enum:
                  - number_recording
                  - forwarding_on_failure
                  - call_screening
                  - off_by_owner
                  - off_until_active
                  - off_while_paused
              description: >
                Telnyx voice settings on the number that configuring leaves on
                (recording, forwarding when

                unanswered, call screening). They stay as they are when you
                configure it. When the number is

                switched off (`is_active` is `false`, so it places no calls),
                one more note says why:

                `off_by_owner` (an owner or admin switched it off; it stays off
                until one switches it on),

                `off_until_active` (Telnyx did not list it as active; the sync
                switches it on once Telnyx does)

                or `off_while_paused` (its carrier account paused; turning the
                account back on switches it on).
            removed_at:
              type: string
              format: date-time
              nullable: true
              description: >-
                When the number went out of use here, on a `telnyx_gone` or
                `removed` number. `null` on every other.
        ownership_verified_at:
          type: string
          format: date-time
          nullable: true
          description: >
            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](/api-reference/carrier-accounts/test) or
            a sync

            finds it again. Always `null` on numbers bought from Yappr.
    Error:
      type: object
      required:
        - error
        - code
      description: >
        Every error response - the secret-key API and the browser data plane
        alike - carries a

        human-readable `error` and a stable machine `code`, and a refusal that
        names what is

        wrong with the request carries `issues[]` too. Branch on `code`, never
        on the `error`

        text. A refusal that names nothing more specific carries the code its
        status means:

        `BAD_REQUEST` (400), `UNAUTHORIZED` (401, the browser data plane; the
        secret-key API

        answers `MISSING_KEY`, `INVALID_KEY` or `EXPIRED_KEY`), `BILLING_ERROR`
        (402),

        `FORBIDDEN` (403), `NOT_FOUND` (404), `METHOD_NOT_ALLOWED` (405),
        `CONFLICT` (409),

        `GONE` (410), `PAYLOAD_TOO_LARGE` (413), `UNSUPPORTED_MEDIA_TYPE` (415),

        `UNPROCESSABLE_REQUEST` (422), `RATE_LIMIT` (429), `INTERNAL_ERROR`
        (500),

        `UPSTREAM_ERROR` (502), `SERVICE_UNAVAILABLE` (503), `UPSTREAM_TIMEOUT`
        (504). Some

        refusals add members of their own beside these (a call request's
        `status`, a workflow's

        `current_version`); the operation says which.
      properties:
        error:
          type: string
          description: The refusal, in one sentence for a person. Its wording may change.
        code:
          type: string
          description: The stable code to branch on.
        issues:
          type: array
          description: >
            Each thing at fault, on a 400 or 422 that names them: every query
            parameter or body field, not just the first. `path` is the
            parameter's name or the field's location.
          items:
            type: object
            required:
              - code
              - message
            properties:
              code:
                type: string
                description: >-
                  query_param_unknown, query_param_repeated, query_param_blank,
                  query_param_invalid, field_unknown, field_required,
                  field_invalid, or the route's own word.
              path:
                type: string
              message:
                type: string
    PhoneNumberRent:
      type: object
      required:
        - included
        - reason
        - monthly_price_cents
        - last_charged_at
      properties:
        included:
          type: boolean
          description: >
            False when a rent was charged for the number in the last 40 days
            (each renewal is a phone_number row on GET /billing/transactions);
            true when none was.
        reason:
          type: string
          nullable: true
          enum:
            - own_carrier
            - not_charged
            - no_subscription
            - phone_system
            - null
          description: >
            Why the rent is included: `own_carrier` - a number in your own
            Telnyx account, whose rent Telnyx bills you; `not_charged` - a
            monthly subscription is on record but has charged nothing in the
            last 40 days; `no_subscription` - a Yappr number with no
            subscription (one Yappr set up for you); `phone_system` - a number
            that calls out through your own phone system, which Yappr does not
            rent. Null when the rent is charged.
        monthly_price_cents:
          type: integer
          nullable: true
          description: The monthly rent before VAT, paid by card. Null when included.
        last_charged_at:
          type: string
          format: date-time
          nullable: true
          description: The newest rent charge in the last 40 days, or null.
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        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`).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.