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

# Cancel a Browser Session

> The browser data plane, not the secret-key API: the session's `cancel_url` from POST /calls {"type":"web"}. Authorized by the session token itself, sent as `x-yappr-web-token`, so your server or the page you handed the token to can take back a session nobody will use. Send no body, or `{}`. The token is spent so no browser can use it; an `offer` session's call settles at once as POST /calls/{id}/end settles it. Safe to repeat. Once cancelled, a browser that still presents the token is refused `403 WEB_SESSION_CANCELLED` by the offer and by the call request alike. Once a page has created a call request with the token, this cancels that request as POST /call-requests/{id}/cancel does, and the answer names it (`request_id`).


The **browser data plane**: the session's `cancel_url` from
[`POST /calls`](https://docs.goyappr.com/api-reference/calls/create) with `"type": "web"`. It takes back a session
nobody will use, from your server or from the page you handed the token to. It is
authorized by the session token itself, as `x-yappr-web-token` - never your secret key.

```bash theme={null}
curl -X POST https://api.goyappr.com/web-call/cancel \
  -H "x-yappr-web-token: wcs_…"
```

```json theme={null}
{ "status": "cancelled", "call_id": "75a8e137-…" }
```

Send no body, or `{}`. The token is spent so no browser can use it. An `offer` session's
call settles at once, exactly as [`POST /calls/{id}/end`](https://docs.goyappr.com/api-reference/calls/end) settles
it, and `call_id` names it; a `call_request` session answers `call_id: null`, because its
call does not exist yet. This is the only way to take back a `call_request` session.

Sending it again answers the same. A token that has already expired answers
`"status": "expired"`: there is nothing left to take back.

A cancelled token stays cancelled. A browser that still presents it is refused
`403 WEB_SESSION_CANCELLED` by the [offer](https://docs.goyappr.com/api-reference/web-call/offer.md), by
[TURN Credentials](https://docs.goyappr.com/api-reference/web-call/turn-credentials.md) and by
[Create Browser Call Request](https://docs.goyappr.com/api-reference/web-call/request-create.md), so a page can tell a
session you took back from one that ran out.

| Status | Code | When |
| - | - | - |
| `400` | `WEB_SESSION_CANCEL_INVALID` | A body with a field in it, or one that is not JSON. Send none, or `{}`. |
| `401` | `UNAUTHORIZED` | No token, or one that is not a session token. |
| `405` | `METHOD_NOT_ALLOWED` | Use `POST`. |
| `409` | `WEB_SESSION_ALREADY_USED` | A browser already used this token. End the call it started, or cancel the call request it created with that request's own `cancel_url`. |


## OpenAPI

````yaml POST /web-call/cancel
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/cancel:
    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: Cancel a browser session (data plane)
      description: >
        The browser data plane, not the secret-key API: the session's
        `cancel_url` from POST /calls {"type":"web"}. Authorized by the session
        token itself, sent as `x-yappr-web-token`, so your server or the page
        you handed the token to can take back a session nobody will use. Send no
        body, or `{}`. The token is spent so no browser can use it; an `offer`
        session's call settles at once as POST /calls/{id}/end settles it. Safe
        to repeat. Once cancelled, a browser that still presents the token is
        refused `403 WEB_SESSION_CANCELLED` by the offer and by the call request
        alike. Once a page has created a call request with the token, this
        cancels that request as POST /call-requests/{id}/cancel does, and the
        answer names it (`request_id`).
      operationId: cancelWebSession
      parameters:
        - in: header
          name: x-yappr-web-token
          required: true
          schema:
            type: string
          description: The session token (`wcs_…`).
      responses:
        '200':
          description: >-
            Cancelled (or already expired). `call_id` is null for a
            `call_request` session. A token that created a call request answers
            with that request cancelled and its `request_id`.
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - call_id
                properties:
                  status:
                    type: string
                    enum:
                      - cancelled
                      - expired
                  call_id:
                    type:
                      - string
                      - 'null'
                    format: uuid
                  request_id:
                    type: string
                    format: uuid
                    description: >-
                      Only when the token created a call request - the request
                      this cancelled.
        '400':
          description: >-
            WEB_SESSION_CANCEL_INVALID — a body with a field in it, or one that
            is not JSON. Send none, or `{}`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: No token, or one that is not a session token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '405':
          description: Use POST here.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            WEB_SESSION_ALREADY_USED — a browser spent this token on a one-shot
            offer; end the call it started. CALL_REQUEST_FINAL — the call
            request this token created already failed, expired or became a call;
            the body carries its status, error_code, call_id and request_id, and
            nothing was written.
          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.