---
title: "Cancel a WebMCP invocation"
method: POST
path: "/api/session/{id}/webmcp/invocations/{invocationId}/cancel"
---

# Cancel a WebMCP invocation

`POST /api/session/{id}/webmcp/invocations/{invocationId}/cancel`

## Request

- Base URL: `https://api.hyperbrowser.ai`
- URL: `https://api.hyperbrowser.ai/api/session/{id}/webmcp/invocations/{invocationId}/cancel`
- Auth: API key in header `x-api-key`
- TypeScript: <https://skmtc.dev/hyperbrowser/apis/hyperbrowser-api/docs/api/session/:id/webmcp/invocations/:invocationId/cancel/post.ts> (a function with typed inputs; its response is checked against the schema)

Request best-effort cancellation and return the current handle. Completion can win the race. This does not roll back page side effects. Continue result reads if still pending. Requires an active session created with enableWebMcp: true and an API key with browser.sessions.update permission.

## Path parameters

- `id` string, uuid, required
- `invocationId` string, required

## Response `200`

Success

- WebMCPInvocation: Ephemeral, session-local handle. Pending states have no result or error. A terminal handle may contain a result or an error. Lost on receiver restart, session rebind, or browser shutdown. At most 16 active and 64 retained; terminal results expire after 10 minutes and may be evicted sooner.
  - `invocationId` string, required
  - `toolRef` string, required
  - `status` 'running' | 'awaiting_submission' | 'completed' | 'error' | 'canceled' | 'outcome_unknown', required
  - `cancellationRequested` boolean, required: Whether cancellation was requested, regardless of the final outcome.
  - `createdAt` string, date-time, required
  - `expiresAt` string, date-time: Nominal terminal-result expiry. Results may be evicted earlier.
  - `result` WebMCPInvokeResult
    - `invocationId` string: Handle for subsequent result reads or cancellation, when provided.
    - `status` 'completed' | 'error' | 'canceled' | 'awaiting_submission', required
    - `output` unknown
    - `errorText` string
    - `outputBytes` integer, required: Byte length of the original JSON output.
    - `outputTruncated` boolean: True when output exceeds 1 MiB. Full output is withheld.
    - `outputPreview` string: At most 4096 UTF-8 bytes of the oversized output; may be incomplete JSON.
    - `untrustedContent` boolean, required
    - `durationMs` integer, required
  - `error` WebMCPInvocationError
    - `code` string, required
    - `message` string, required

## Other responses

- `400`: Invalid request or tool reference.
- `401`: Authentication required.
- `403`: Insufficient API key permission.
- `404`: Session, tool, or invocation not found. Expired handles return invocation_not_found.
- `409`: Session is stopped, unavailable, or was not created with WebMCP enabled.
- `429`: Rate limit reached; too_many_invocations indicates 16 active invocations.
- `500`: Internal server error.
- `502`: WebMCP service unavailable.
- `504`: Request timed out. For invocation requests, outcome_unknown means the tool may have acted.

## Changes

- **2026-10-11** `6bf1269eede9`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/hyperbrowser/apis/hyperbrowser-api/changes/api/session/:id/webmcp/invocations/:invocationId/cancel/post.md)

---

[API](https://skmtc.dev/hyperbrowser/apis/hyperbrowser-api.md) - [All operations](https://skmtc.dev/hyperbrowser/apis/hyperbrowser-api/llms.txt) - [OpenAPI document](https://skmtc.dev/hyperbrowser/apis/hyperbrowser-api/revisions/ef089024c533?raw)
