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

# Sandboxes, Volumes & Images SDK Reference

> Node.js and Python SDK methods for sandbox lifecycle, exec, processes, terminals, files, networking, volumes, snapshots, and custom image builds

Use `client.sandboxes` and `client.volumes` to run isolated Linux sandboxes.

> [!NOTE]
>
> **Surface parity:** macOS sandboxes and Persistent Disks (`/api/disks`) are currently available via the REST API and [`hx vm`](https://hyperbrowser.ai/docs/cli/sandboxes) CLI.

***

## Sandbox Lifecycle, Networking & Snapshots

| Operation | Node.js (`@hyperbrowser/sdk`) | Python (`hyperbrowser`) |
| - | - | - |
| Create sandbox | `client.sandboxes.create(params)` | `client.sandboxes.create(params)` |
| Boot from snapshot | `client.sandboxes.startFromSnapshot(params)` | `client.sandboxes.start_from_snapshot(params)` |
| Connect / attach / get / list | `client.sandboxes.connect(id)` / `attach(detail)` / `get(id)` / `list(params?)` | `client.sandboxes.connect(id)` / `attach(detail)` / `get(id)` / `list(params=None)` |
| Stop sandbox | `sandbox.stop()` | `sandbox.stop()` |
| Create memory snapshot | `sandbox.createMemorySnapshot(params)` | `sandbox.create_memory_snapshot(params)` |
| List / get / delete snapshots | `client.sandboxes.listSnapshots` / `getSnapshot` / `deleteSnapshot` | `client.sandboxes.list_snapshots` / `get_snapshot` / `delete_snapshot` |
| Expose / unexpose port | `sandbox.expose(params)` / `sandbox.unexpose(port)` | `sandbox.expose(params)` / `sandbox.unexpose(port)` |
| Update / clear egress policy | `sandbox.updateNetwork(patch)` / `sandbox.clearNetwork()` | `sandbox.update_network(patch)` / `sandbox.clear_network()` |

## Execution, Processes, Terminal & Files

| Operation | Node.js | Python |
| - | - | - |
| One-shot command | `sandbox.exec(cmd, opts?)` | `sandbox.exec(cmd, ...)` |
| Background processes | `sandbox.processes.start` / `get` / `list` | `sandbox.processes.start` / `get` / `list` |
| Start process with secrets | `client.sandboxes.startSecretProcess(id, params)` | `client.sandboxes.start_secret_process(id, params)` |
| Interactive PTY terminal | `sandbox.terminal.create` / `get`, then `terminal.attach()` | `sandbox.terminal.create` / `get`, then `terminal.attach()` |
| Filesystem CRUD & watch | `sandbox.files.list` / `read` / `write` / `upload` / `download` / `mkdir` / `remove` / `watch` | `sandbox.files.list` / `read` / `write` / `upload` / `download` / `mkdir` / `remove` / `watch` |

## Volumes & Custom Images

| Operation | Node.js | Python |
| - | - | - |
| Volumes CRUD | `client.volumes.create` / `list` / `get` / `delete` | `client.volumes.create` / `list` / `get` / `delete` |
| List / delete images | `client.sandboxes.listImages` / `deleteImage` | `client.sandboxes.list_images` / `delete_image` |
| Build or reuse image | `client.sandboxes.getOrBuildImage` / `buildImageFromDockerfile` / `buildImageFromDockerImage` / `reuseDockerImage` | `client.sandboxes.get_or_build_image` / `build_image_from_dockerfile` / `build_image_from_docker_image` / `reuse_docker_image` |
| Manage image builds | `createImageBuild` / `listImageBuilds` / `getImageBuild` / `waitForImageBuild` / `cancelImageBuild` | `create_image_build` / `list_image_builds` / `get_image_build` / `wait_for_image_build` / `cancel_image_build` |

```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { Hyperbrowser } from "@hyperbrowser/sdk";

const client = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY });
const sandbox = await client.sandboxes.create({ imageName: "node" });

try {
  await sandbox.files.writeText("/tmp/hello.js", "console.log('ok');\n");
  const res = await sandbox.exec("node /tmp/hello.js");
  console.log(res.stdout.trim());
} finally {
  await sandbox.stop();
}
```

```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import os
from hyperbrowser import Hyperbrowser

client = Hyperbrowser(api_key=os.environ["HYPERBROWSER_API_KEY"])
sandbox = client.sandboxes.create({"image_name": "node"})

try:
    sandbox.files.write_text("/tmp/hello.js", "console.log('ok');\n")
    res = sandbox.exec("node /tmp/hello.js")
    print(res.stdout.strip())
finally:
    sandbox.stop()
```


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