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

> ## Agent Instructions
> Authenticate REST, SDK, and CLI requests with the `x-api-key` header using the `HYPERBROWSER_API_KEY` environment variable (create keys at https://app.hyperbrowser.ai).
> Always stop browser sessions (`sessions.stop(id)` / `PUT /api/session/{id}/stop`) and sandboxes (`sandboxes.stop(id)` / `PUT /api/sandbox/{id}/stop`) in `try`/`finally` blocks to avoid idle billing.
> Choose the right surface: use Web API (`/api/web/fetch`, `batch-fetch`, `crawl`, `search`) for stateless reading and extraction (prefer it over legacy `/api/scrape`); Browser Sessions (`/api/session`) for interactive, authenticated, or Playwright/Puppeteer workflows; Cloud Agents (`/api/task/*`) for autonomous browser tasks; and Sandboxes (`/api/sandbox`) for isolated Linux or macOS code execution.
> Use `@hyperbrowser/sdk` for Node.js/TypeScript, `hyperbrowser` 1.0+ typed-dict request params for Python (avoid legacy Pydantic request classes), the unified `hx` CLI for terminal workflows, and hosted OAuth MCP at `https://mcp.hyperbrowser.ai/mcp/web` (web tools; use `https://mcp.hyperbrowser.ai/mcp` only when browser, sandbox, admin, and usage tools are needed).

# API Conventions

> Base URL, authentication headers, error format, pagination, retries, and OpenAPI specification for the Hyperbrowser REST API

The Hyperbrowser REST API is organized around resource-oriented URLs, accepts JSON request bodies (and `multipart/form-data` for file/extension uploads), returns JSON responses, and uses standard HTTP status codes.

* **Base URL:** `https://api.hyperbrowser.ai`
* **OpenAPI 3.0.1 Specification:** [`https://www.hyperbrowser.ai/docs/openapi.json`](https://www.hyperbrowser.ai/docs/openapi.json)
* **Official Clients:** [Node.js / TypeScript SDK](https://hyperbrowser.ai/docs/sdks/node.md), [Python SDK](https://hyperbrowser.ai/docs/sdks/python.md), and the unified [`hx` CLI](https://hyperbrowser.ai/docs/cli/overview).

***

## Authentication

Pass your API key in the `x-api-key` HTTP header on every `/api/*` request:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl https://api.hyperbrowser.ai/api/sessions \
  -H "x-api-key: $HYPERBROWSER_API_KEY"
```

Create unrestricted or least-privilege scoped API keys in the [Hyperbrowser Dashboard](https://app.hyperbrowser.ai). See [Authentication & Scoped API Keys](https://hyperbrowser.ai/docs/platform/authentication.md) for the full scope catalog, OAuth 2.0 Bearer auth for Hosted MCP, and X402 pay-per-request JWT auth (`/x402/*`).

> [!NOTE]
>
> `GET /api/secrets/public-key` is publicly readable without authentication so SDKs can fetch the encryption key before uploading secrets.

***

## Content Types & Versioning

* **Request & response format:** Set `Content-Type: application/json` for JSON bodies. File upload endpoints (`POST /api/session/{id}/uploads`, `POST /api/extensions/add`) use `multipart/form-data`.
* **Timestamps:** ISO 8601 UTC strings (for example, `"2026-04-01T12:00:00.000Z"`) or Unix epoch milliseconds where noted in the endpoint schema.
* **Identifiers:** UUID v4 strings unless a resource explicitly supports human-readable names/keys (such as sandbox images, snapshots, volumes, secrets, and vaults).
* **API stability:** New optional fields may be added to responses without a breaking version bump. Ignore unknown response fields when deserializing.

***

## Error Envelope & Status Codes

Failed requests return a JSON error body with a `message` string explaining the cause (authentication and scope rejections use `error` instead):

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "message": "Session not found"
}
```

| Status | Meaning | Retry? |
| - | - | - |
| `400` | Invalid request body, query params, or path params | No — fix the request |
| `401` | Missing, invalid, or revoked API key | No — check `x-api-key` |
| `402` | Insufficient credits or plan upgrade required | No — add credits or upgrade |
| `403` | Missing API key scope or team feature not enabled | No — adjust key scopes or plan |
| `404` | Resource not found (or belongs to another team) | No |
| `409` | Conflict (for example, session already stopped, or resource in use) | Only after resolving state |
| `413` | Payload exceeds size limit (for example, >200 MB upload) | No — reduce payload size |
| `429` | Rate limit or concurrent session/sandbox limit reached | Yes — exponential backoff with jitter |
| `500` / `503` | Transient server or upstream error | Yes — exponential backoff with jitter |

See [Rate Limits & Errors](https://hyperbrowser.ai/docs/platform/rate-limits-and-errors.md) for concurrency ceilings, retry templates, and troubleshooting.

***

## Pagination

List endpoints accept `page` (1-indexed) and `limit` query parameters (or `offset` + `limit` on `/api/disks`) and return `totalCount` alongside the requested page. `GET /api/session/{id}/event-logs` also supports optional `startTimestamp` and `endTimestamp` filters alongside `page` and `limit`:

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "sessions": [...],
  "totalCount": 142,
  "page": 1,
  "perPage": 20
}
```

***

## Async Jobs & Idempotency

* **Async jobs (`200`/`201` with `jobId`):** Endpoints such as `POST /api/web/fetch/job`, `POST /api/web/batch-fetch`, `POST /api/web/crawl`, `POST /api/task/*`, and legacy scraping endpoints enqueue background work. Poll the sibling `/status` endpoint (`pending` -> `running` -> `completed` | `failed` | `stopped`) before fetching full results.
* **Idempotency:** Persistent disk creation (`POST /api/disks`) and disk snapshots (`POST /api/disks/{id}/snapshot`) accept a client-supplied UUID `id` for safe idempotent retries. `PUT /api/session/{id}/stop` and `PUT /api/sandbox/{id}/stop` are idempotent on already-stopped resources.
* **Cleanup invariant:** Always stop active browser sessions (`PUT /api/session/{id}/stop`) and sandboxes (`PUT /api/sandbox/{id}/stop`) in a `finally` block to avoid idle billing.


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