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

# boxd plugin

> boxd cloud machines through boxd's TypeScript SDK: create, list, start, stop, pause, hibernate, wake, fork and delete full Linux VMs, run commands, move files in and out, publish ports on HTTPS URLs or raw TCP/UDP, and save and restore snapshots and checkpoints (35 operations).

Use **boxd** through Corsair: one client, typed API calls.

[boxd](https://boxd.sh?ref=corsair) machines are full Ubuntu 24.04 VMs
(user `boxd` with sudo, Docker, Node, Python, Go and git) with a persistent
disk and a public HTTPS URL. Connect an account with an API key from
`boxd auth keys create <name> --org <org>` or the boxd console. A key
belongs to one org: machines are created and listed there unless an
operation gets `org`, or the plugin is set up with `boxd({ org: 'acme' })`.
`boxd({ region: 'fra' })` pins the region the same way.

* **The SDK.** Everything goes over gRPC through boxd's official SDK, so the
  plugin runs on Node 20 or newer. The SDK loads the first time an operation
  runs; each call makes its own client from the account's key and closes it
  after. The host's `BOXD_API_KEY`, `BOXD_TOKEN`, `BOXD_BASE_URL` and
  `BOXD_REGION` are never used for an account.
* **Money.** A machine bills while it runs. `machines.create`, `fork`,
  `start`, `wake`, `resume` and `exec` (it can wake a hibernated machine) are
  `destructive`, as are `stop` (memory is lost), every delete,
  `files.remove` and `snapshots.create` (saving over a name changes what
  later restores get). A hibernated machine keeps its memory and processes
  on disk and stops using compute; `machines.hibernate` is `write`.
* **Isolation.** `machines.create` makes isolated machines unless it gets
  `isolated: false`: they join no network with the org's other machines and
  hold no boxd credentials, so code they run can't reach either.
* **Ready means ready.** `machines.create`, `fork`, `start` and `wake` wait
  until the machine runs and answers a command, unless `waitUntilReady` is
  false. If the wait fails, the error (504 on timeout) carries the
  `machineId` of the machine that exists: wait again or delete it.
  `snapshots.create` waits until the version it saved is `ready`.
* **Commands.** `machines.exec` runs a shell line or an argv array as user
  `boxd`, with `env` and `cwd`, and returns the exit code, stdout and stderr
  (each capped at `maxOutputBytes`, 1 MB by default, while it streams). It ends the command
  after `timeoutMs` (5 minutes by default, 30 at most) with a 504. stdin is
  closed. A machine in standby or hibernated wakes by itself; a stopped one
  answers 409 until `machines.start`.
* **Files** go as text or base64. `files.download` refuses a file larger
  than `maxBytes` (5 MB by default) with a 413.
* **Publishing.** `proxies.create` puts a port of the machine on its own
  HTTPS URL (`https://<name>.<machine>.boxd.sh`), which answers once its
  certificate is issued, about 15 seconds. The machine's default URL has
  bot protection (`botProtection` on a machine): browsers pass, API
  clients and webhooks don't, so give those a named route.
  `ports.expose` forwards a raw TCP or UDP port (at most 3 per machine).
* **Checkpoints** save one machine in place, memory and disk:
  `checkpoints.restore` reboots it into the checkpoint, and everything
  since is lost. Snapshots instead make new machines.
* **Retries.** Only reads are retried: by the SDK on a connection failure,
  and by the plugin on a plain rate limit. Writes and multi-step operations
  (create, fork, start, wake, snapshots.create) are sent once.
* Not wrapped: machine specs and settings (resize, rename, reboot,
  delete-after timers, bot protection, SSH), custom domains, networks and
  egress rules, backups, disks, snapshot versions, the desktop and computer
  use API, coding agent sessions, env vars and secrets, org and account
  settings, and API keys.

**What you get:**

* 35 typed API operations

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/boxd better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/boxd better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/boxd better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/boxd better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { boxd } from '@corsair-dev/boxd';

export const corsair = createCorsair({
	plugins: [
		boxd(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] API Key (Recommended)
>
> Store the boxd API key before the first call: `pnpm corsair setup --plugin=boxd --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> boxd()
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'boxd',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**List machines with a label**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.boxd.api.machines.list({
	labels: { env: 'ci' },
});
```

**Run the tests on a machine**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.boxd.api.machines.exec({ machineId: 'ci-runner', command: 'cd app && npm test', timeoutMs: 600000 });
```

See the full list on the [API](https://docs.corsair.dev/plugins/boxd/api.md) page.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/boxd/api.md)
>
> Every `boxd.api.*` operation with input and output types.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


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