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

# Boat plugin

> Persistent Linux sandboxes for AI agents with Boat: create, stop, resume and fork sandboxes, run commands, read and write files, prompt integrated coding agents, expose ports and the desktop, save snapshots, and manage environments, credential profiles, API keys, webhooks, CI and telemetry (125 operations).

Use **Boat** through Corsair: one client, typed API calls, and incoming webhooks.

Create an API key with `boat api-key create <name>` or in the Boat dashboard. Keys start with `boat_` (older `box_` keys still work). Things to know before you write:

* **Which key.** An organization key works on the organization's sandboxes, environments, snapshots, limits and usage. Account settings (webhooks, API keys, credential profiles, CI, telemetry, AI proxy, secrets, repositories, caller address, data retention) answer 403 `api_key_org_forbidden` to it: use a personal account key there. A scoped key (`apiKeys.createScoped`) can be limited to some sandboxes, environments or actions.
* **Sandboxes bill while they run.** `sandboxes.create`, `fork`, `resume` and `recover` start a machine that bills until it stops (`ttlSeconds`, default one hour; `null` turns auto-stop off), so they are `destructive`. `sandboxes.stop` saves the disk and stops billing; a stopped sandbox reads as `archived`. Send `idempotencyKey` with create and fork to make a retry safe. A full start window answers 429 `rate_limited` and is not retried: `account.getLimits` shows `canStart` and what is left.
* **Commands and files** go to the sandbox machine. `sandboxes.commands.run` waits for the command (30 s by default, up to 600 s); start long jobs with `detached: true`, then read `commands.getStatus` or `commands.attach`. A call right after a start can answer 409 `sandbox_starting`: retry after a few seconds. File reads stop at 5 MiB (413); use `files.createDownloadUrl` for bigger files.
* **Integrated agents** (`sandboxes.agent.*`) run Codex, Claude Code, pi, OpenCode and other harnesses inside the sandbox with the model key or subscription connected on the dashboard, so a prompt spends that account's model usage. With no harness set up at all, prompts answer 409 `provider_not_configured`; a prompt to a provider that has no key is accepted and the run fails in the harness (`agent.getPrompt` shows `failed`).
* **Snapshots.** Every stop leaves a snapshot (`snapshots.*`, `sandboxes.snapshots.*`); a fork or resume starts from it. Saved snapshots (`savedSnapshots.*`, with share codes) need a paid plan: the free trial answers 403. A command in the first seconds after a fork or resume can answer 502 `sandbox_restoring` (it did not run): retry after 1-3 s.
* **Deletes** of sandboxes and snapshots take the id a second time as `confirm`, Boat's guard against deleting the wrong one.
* **Webhooks.** Boat posts sandbox lifecycle events (`sandbox.ready`, `hydrated`, `error`, `archived`, `degraded`, `recovered`) to endpoints made with `webhooks.create`, signed with HMAC-SHA256 (`X-Ascii-Signature`). The plugin checks the signature with the endpoint's `whsec_` secret.

**What you get:**

* 125 typed API operations
* 6 incoming webhook event types

## Setup

**1. Install**

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

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

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

```bash bun theme={null}
bun add corsair @corsair-dev/boat 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 { boat } from '@corsair-dev/boat';

export const corsair = createCorsair({
	plugins: [
		boat(),
	],
	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 Boat API key before the first call: `pnpm corsair setup --plugin=boat --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}
> boat()
> ```
>
> 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: 'boat',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**List sandboxes**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.boat.api.sandboxes.list({});
```

**Run a command in a sandbox**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.boat.api.sandboxes.commands.run({ sandboxId: 'bx_23456789', command: 'uname -a', timeoutSeconds: 30 });
```

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

## Webhooks

This plugin registers **6** webhook event types. Configure the provider to POST to your Corsair HTTP handler, then use `webhookHooks` on the plugin factory.

See [Webhooks](https://docs.corsair.dev/plugins/boat/webhooks.md) for every event path and payload shape, and [Webhooks concept](https://docs.corsair.dev/concepts/webhooks.md) for routing.

## What's next

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

> [card] [Webhooks](https://docs.corsair.dev/plugins/boat/webhooks.md)
>
> Event paths, payloads, and `webhookHooks` examples.

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