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

# Test an Agent by Phone

> Requires calls:create. Rings the phone number in `to` with this agent, so you hear it the way a caller will. The call comes from the workspace's own number when it has one, and from a Yappr test line when it has none, so a workspace without a number can still test on a real phone. The Yappr test line places calls only; it never answers one. A key limited to agents calls only from a number one of its agents answers or calls from, as on POST /calls; with none, the Yappr test line calls. GET on this path says which line it will be.
A test call is an ordinary outbound phone call for the workspace: billed per minute at the phone rate of the agent's model, from the workspace's credit, whichever line it comes from, and recorded with source "test" on GET /calls. It is checked like any other outbound call (a diallable number, the Do-Not-Call list, the outbound call window, the monthly spending limit and the credit floor, and capacity), with no limit of its own on how many you place. Two answers differ from POST /calls because someone is waiting on the phone: outside the call window, and when every line is busy, the test is refused rather than scheduled or queued.
For an agent that does not run a workflow the call is created at once (201, with its id). A workflow agent's call is a phone call request (202, with request_id and call_id null) that the workflow prepares and dials within seconds; follow it with GET /call-requests/{id} until call_id is set, then GET /calls/{id}.


Ring your own phone with an agent, with `calls:create`, to hear it the way a caller will. You send
only the number to ring; Yappr picks the number that calls:

* **Your workspace's own number**, when it has one: a number the agent calls from first (including as
  the other half of an outbound split), then the from-number of a campaign it runs, then a number it
  answers on, then any other active number in the workspace. At each step a Yappr-hosted number comes
  before one on your own Telnyx account.
* **A Yappr test line**, when the workspace has no number yet. It places calls only and never answers
  one, so nobody can call your agent through it.

A key [limited to agents](https://docs.goyappr.com/api-reference/introduction.md#limiting-a-key-to-some-agents) calls only from a number one of its agents
answers or calls from, as on [`POST /calls`](https://docs.goyappr.com/api-reference/calls/create): any other number is
another client's caller ID. With none, the Yappr test line calls.

[`GET /agents/{id}/test-call`](https://docs.goyappr.com/api-reference/agents/test-call-caller) tells you which one it will
be, without placing anything.

```bash theme={null}
curl --request POST "$YAPPR_API_URL/agents/$AGENT_ID/test-call" \
  --header "Authorization: Bearer $YAPPR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"to": "+972501234567", "variables": {"FirstName": "Dana"}}'
```

| Field | Test call |
| - | - |
| `to` | Required. The phone to ring, in E.164 format (`+972501234567`). There is no `from`: the number that calls is chosen for you. |
| `variables` | Optional. Values for the agent's template variables, as on [`POST /calls`](https://docs.goyappr.com/api-reference/calls/create). |

## What it costs

A test call is an ordinary outbound phone call for your workspace. It is billed per minute at the
phone rate of the agent's model, from your credit, whichever line it comes from. It appears in your
call logs and on `GET /calls` with `source: "test"`.

## What is checked

The same things every outbound call is checked for: a number that can be dialled, your
[Do-Not-Call list](https://docs.goyappr.com/api-reference/do-not-call/add.md), your outbound call window, your monthly
spending limit and the \$1.00 credit floor, and capacity. There is no limit on how many test calls
you place. Two answers differ from `POST /calls`, because someone is waiting on the phone: outside
your call window the test is refused (`422 OUTSIDE_CALL_WINDOW`) instead of being scheduled for the
next opening, and when every line is busy it is refused (`503 AT_CAPACITY`) instead of being queued.

## The answer

For an agent that does not run a workflow the call is placed at once:

```json theme={null}
{
  "id": "6f1c2d0e-4b8a-4e7f-9c3d-2a1b0c9d8e7f",
  "call_id": "6f1c2d0e-4b8a-4e7f-9c3d-2a1b0c9d8e7f",
  "request_id": null,
  "status": "ringing",
  "agent_id": "a1b2c3d4-0000-4000-8000-000000000001",
  "to": "+972501234567",
  "from": "+972555000111",
  "caller_line": "workspace"
}
```

A workflow agent's call is a phone call request, answered `202` with `request_id` set and `call_id`
`null`. The workflow prepares and dials it within seconds: poll
[`GET /call-requests/{id}`](https://docs.goyappr.com/api-reference/calls/request-get) until `call_id` is set, then read the call
with [`GET /calls/{id}`](https://docs.goyappr.com/api-reference/calls/get). Send an `Idempotency-Key` header to make a retry
return the same request instead of ringing again.

`caller_line` is `workspace` when one of your numbers called and `yappr` when a Yappr test line did.

## Errors

| Status | Code | Meaning |
| - | - | - |
| 400 | `invalid_destination` | `to` cannot be dialled. Calls can only be placed to Israeli numbers: `+972` followed by 8 or 9 digits. |
| 400 | `SELF_CALL_NOT_ALLOWED` | `to` is the number the test calls from. |
| 400 | `TEST_CALL_INVALID` | The body carried a field other than `to` and `variables`. |
| 402 | `BILLING_ERROR`, `SPEND_BUDGET_REACHED` | The workspace cannot pay for a call now, or its monthly limit is reached. |
| 404 | `AGENT_NOT_FOUND` | No agent with this id in this workspace. |
| 409 | `AGENT_INACTIVE`, `WORKFLOW_UNPUBLISHED` | Switch the agent on, or publish its workflow. |
| 422 | `NO_CALLER_NUMBER` | No number to call from: add a phone number, or test in the browser. |
| 422 | `DESTINATION_ON_DNC` | `to` is on your Do-Not-Call list. |
| 422 | `OUTSIDE_CALL_WINDOW` | Outside your outbound call window. |
| 422 | `DESTINATION_OUTSIDE_PHONE_SYSTEM_COUNTRY` | The number that would call goes out [through your phone system](https://docs.goyappr.com/concepts/sip-trunks.md#outbound-calls-through-the-extension) in `national` dial format, which reaches Israeli numbers only, and `to` is outside Israel. |
| 503 | `AT_CAPACITY` | Every line is busy. Try again in a minute. |


## OpenAPI

````yaml POST /agents/{id}/test-call
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:
  /agents/{id}/test-call:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
          format: uuid
    post:
      tags:
        - Agents
      summary: Test an agent by phone
      description: >
        Requires calls:create. Rings the phone number in `to` with this agent,
        so you hear it the way a caller will. The call comes from the
        workspace's own number when it has one, and from a Yappr test line when
        it has none, so a workspace without a number can still test on a real
        phone. The Yappr test line places calls only; it never answers one. A
        key limited to agents calls only from a number one of its agents answers
        or calls from, as on POST /calls; with none, the Yappr test line calls.
        GET on this path says which line it will be.

        A test call is an ordinary outbound phone call for the workspace: billed
        per minute at the phone rate of the agent's model, from the workspace's
        credit, whichever line it comes from, and recorded with source "test" on
        GET /calls. It is checked like any other outbound call (a diallable
        number, the Do-Not-Call list, the outbound call window, the monthly
        spending limit and the credit floor, and capacity), with no limit of its
        own on how many you place. Two answers differ from POST /calls because
        someone is waiting on the phone: outside the call window, and when every
        line is busy, the test is refused rather than scheduled or queued.

        For an agent that does not run a workflow the call is created at once
        (201, with its id). A workflow agent's call is a phone call request
        (202, with request_id and call_id null) that the workflow prepares and
        dials within seconds; follow it with GET /call-requests/{id} until
        call_id is set, then GET /calls/{id}.
      operationId: testAgentByPhone
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: >-
            Workflow agents only. Replaying the same key returns the same call
            request instead of ringing again.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - to
              properties:
                to:
                  type: string
                  description: >-
                    The phone to ring, in E.164 format (e.g. +972501234567). The
                    number that calls is chosen for you; there is no from.
                variables:
                  type: object
                  additionalProperties:
                    type: string
                  description: >-
                    Values for the agent's template variables, as on POST
                    /calls.
            example:
              to: '+972501234567'
              variables:
                FirstName: Dana
      responses:
        '201':
          description: The call was placed (an agent that does not run a workflow).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentTestCall'
        '202':
          description: >
            A workflow agent's call request was accepted (request_id set,
            call_id null), or the calling service was briefly unavailable and
            the call was queued.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentTestCall'
        '400':
          description: >
            invalid_destination — `to` is not a number that can be dialled
            (E.164, and calls can only be placed to Israeli numbers: +972
            followed by 8 or 9 digits). SELF_CALL_NOT_ALLOWED — `to` is the
            number the test calls from. TEST_CALL_INVALID — the body carried a
            field other than `to` and `variables`. AGENTS_QUERY_INVALID — a
            query parameter was sent.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: >
            BILLING_ERROR — the workspace cannot pay for a call now (a call
            needs at least $1.00 of credit, after any auto top-up).
            SPEND_BUDGET_REACHED — the workspace's own monthly spending limit is
            reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            AGENT_NOT_FOUND — no agent with this id in this workspace, or it is
            archived.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >
            AGENT_INACTIVE — the agent is switched off. WORKFLOW_UNPUBLISHED — a
            workflow agent with no published version.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >
            NO_CALLER_NUMBER — the workspace has no number and no Yappr test
            line is available; add a number, or test in the browser.
            DESTINATION_ON_DNC — `to` is on the workspace's Do-Not-Call list.
            OUTSIDE_CALL_WINDOW — it is outside the workspace's outbound call
            window. TEST_CALL_INVALID — `to` is missing or not text, or
            `variables` is not an object of text values.
            DESTINATION_OUTSIDE_PHONE_SYSTEM_COUNTRY — the number that would
            call goes out through your phone system's extension in `national`
            dial format, which reaches Israeli numbers only, and `to` is outside
            Israel. A carrier refusal of the number itself is answered as on
            POST /calls.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >
            AT_CAPACITY — every line is busy; try again in a minute.
            BILLING_UNAVAILABLE — a top-up is still settling; retry shortly.
            TEST_CALL_UNAVAILABLE or WORKFLOW_ADMISSION_UNAVAILABLE — the call
            could not be placed just now; no call was placed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AgentTestCall:
      type: object
      required:
        - agent_id
        - to
        - from
        - caller_line
        - status
      properties:
        id:
          type: string
          format: uuid
          description: The call's id (agents that do not run a workflow).
        call_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            The call's id; null on a workflow agent's request until the call is
            placed.
        request_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            A workflow agent's call request; follow it with GET
            /call-requests/{id}.
        status:
          type: string
          description: ringing, queued or scheduled.
        agent_id:
          type: string
          format: uuid
        to:
          type: string
        from:
          type: string
          description: The number that calls.
        caller_line:
          type: string
          enum:
            - workspace
            - 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
  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.