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

# Connect a Browser Call

> The browser data plane: the mint's `connection.web_call_url`, where `@goyappr/client` posts the browser's SDP offer for a session minted with `protocol: "offer"`. Authorized by the session token as `x-yappr-web-token` (a shared link's page sends `x-share-token`, the dashboard its own sign-in), never the secret key. The token is single-use: the first offer spends it, and the call it starts is the session's `call_id`. An agent whose mint answers `protocol: "call_request"` is a workflow agent (steps or not) the workflow engine runs, and is refused here before the token is spent; use the call request below.


The **browser data plane**, not the secret-key API: the mint's `connection.web_call_url`,
where the browser posts its SDP offer for a session minted with
`protocol: "offer"` by [`POST /calls`](https://docs.goyappr.com/api-reference/calls/create) with `"type": "web"`.
`@goyappr/client` makes this call for you; call it yourself only if you build the peer
connection without the SDK.

It is authorized by the session token as `x-yappr-web-token` (a shared link's page sends
`x-share-token`, the dashboard its own sign-in) - never your secret key, so the browser
calls it directly.

```bash theme={null}
curl -X POST https://api.goyappr.com/web-call \
  -H "x-yappr-web-token: wcs_…" \
  -H "Content-Type: application/json" \
  -d '{ "sdp": "v=0…", "type": "offer" }'
```

```json theme={null}
{
  "call_id": "75a8e137-…",
  "agent_name": "Front desk",
  "sdp": "v=0…",
  "type": "answer",
  "pc_id": "…",
  "ice_candidate_url": "https://voice.goyappr.com/api/web-call/offer"
}
```

## One offer per token

The token is single-use: the first offer spends it, and the call it starts is the
session's `call_id` - the one the mint already answered with. Fetch the ICE servers
first with [TURN Credentials](https://docs.goyappr.com/api-reference/web-call/turn-credentials.md), which does not
spend it. After the answer, trickle candidates to `ice_candidate_url` with `pc_id`, and
`DELETE` that URL with `pc_id` to hang up.

An agent whose mint answered `protocol: "call_request"` is a workflow agent, with or without
steps; a one-shot offer starts no workflow run, so the call would run without its tools. Its
offer is refused with `409 workflow_preparation_required` **before** the token is spent:
create the call with [Create Browser Call Request](https://docs.goyappr.com/api-reference/web-call/request-create.md)
using the same token instead.

## Refusals

| Status | Code | What to do |
| - | - | - |
| `400` | `BAD_REQUEST` | The body is not JSON, or has no `sdp` and `type`. |
| `401` | `UNAUTHORIZED` | No session token, share link or sign-in, or one that is not ours. |
| `403` | `WEB_SESSION_CANCELLED` | The token was taken back with its `cancel_url`. Mint a new session. |
| `403` | `FORBIDDEN` | The token was already used or has expired, or the shared link was revoked or has expired. Mint a new session. |
| `409` | `workflow_preparation_required` | This agent runs on the workflow engine, which a one-shot offer cannot start. Create a browser call request with the same token; nothing was spent. |
| `502` | `VOICE_CONNECTION_REFUSED` | The voice server refused the offer. The call is recorded failed and the token is spent; mint a new session rather than resending the offer. |
| `503` | `VOICE_UNAVAILABLE` | The voice server did not take the offer, or every line was busy. The call is recorded failed and the token is spent; mint a new session and try again in a moment. |

Every refusal is the one [`Error`](https://docs.goyappr.com/api-reference/errors) body, `{error, code}`. Branch on `code`.


## OpenAPI

````yaml POST /web-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:
  /web-call:
    servers:
      - url: https://api.goyappr.com
        description: >-
          Browser data plane, on the API host (the web mint's connection.host).
          Takes a session token, a call request's capability or a shared link -
          never the secret key.
    post:
      tags:
        - Calls
      summary: Connect a browser call (data plane)
      description: >
        The browser data plane: the mint's `connection.web_call_url`, where
        `@goyappr/client` posts the browser's SDP offer for a session minted
        with `protocol: "offer"`. Authorized by the session token as
        `x-yappr-web-token` (a shared link's page sends `x-share-token`, the
        dashboard its own sign-in), never the secret key. The token is
        single-use: the first offer spends it, and the call it starts is the
        session's `call_id`. An agent whose mint answers `protocol:
        "call_request"` is a workflow agent (steps or not) the workflow engine
        runs, and is refused here before the token is spent; use the call
        request below.
      operationId: offerBrowserCall
      parameters:
        - in: header
          name: x-yappr-web-token
          required: false
          schema:
            type: string
          description: The session token (`wcs_…`) from POST /calls {"type":"web"}.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sdp
                - type
              properties:
                sdp:
                  type: string
                  description: The browser's SDP offer.
                type:
                  type: string
                  enum:
                    - offer
      responses:
        '201':
          description: >-
            The call is live. Complete the WebRTC connection with this answer,
            and send ICE candidates to `ice_candidate_url`.
          content:
            application/json:
              schema:
                type: object
                required:
                  - call_id
                  - sdp
                  - type
                  - pc_id
                properties:
                  call_id:
                    type: string
                    format: uuid
                  agent_name:
                    type: string
                  sdp:
                    type: string
                  type:
                    type: string
                    enum:
                      - answer
                  pc_id:
                    type: string
                  ice_candidate_url:
                    type: string
                    format: uri
        '400':
          description: BAD_REQUEST — the body is not JSON, or has no `sdp` and `type`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            UNAUTHORIZED — no session token, share link or sign-in, or one that
            is not one of ours.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >
            WEB_SESSION_CANCELLED — the token was taken back with its
            cancel_url. FORBIDDEN — the token was already used or has expired,
            or the shared link was revoked or has expired. Mint a new session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            workflow_preparation_required — this agent runs on the workflow
            engine, which a one-shot offer cannot start; create a browser call
            request with the same token instead. Nothing was spent.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: >-
            VOICE_CONNECTION_REFUSED — the voice server refused the offer. The
            call is recorded failed and the token is spent; mint a new session
            rather than resending the offer.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            VOICE_UNAVAILABLE — the voice server did not take the offer, or
            every line was busy. The call is recorded failed and the token is
            spent; mint a new session and try again in a moment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security: []
components:
  schemas:
    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.