BoatApi, configure auth, and call methods like sandbox.create, sandbox.prompt, and sandbox.events.
Configure
fetch. Older runtimes need a fetch polyfill. For ESM examples, set "type": "module" in package.json; CommonJS projects can use the require example below.
Create, prompt, and clean up
Use
ttlSeconds when creating a sandbox. Set a friendly name afterward with sandbox.update.Machine size
Passtype to create a bigger Boat. large consumes machine time at 2x, small at half rate. A
fork inherits the source sandbox’s type, and passing type to resume or fork moves a sandbox between
sizes.
Per-sandbox environment variables
Passenv to inject variables into a single sandbox, on top of your account-level secrets
(per-sandbox values win on name conflicts). At most 100 variables, 64KB total.
env unless the fork supplies its own.
No-env sandboxes
When you hand a sandbox to your own end users, create it withnoEnv: true so none of your
account secrets reach it. Model keys, GitHub token, dashboard environment variables, SSH
identity, and secret files are all withheld. SSH, desktop, snapshots, public URLs, and
forks still work. A fork of a no-env Boat is always no-env and cannot be downgraded.
CommonJS
Methods
All methods are called onBoatApi with one object. For a method that takes a request body, put the body’s fields (...body below) directly in that object next to the path and query parameters: saveNamedSnapshot({ sandboxId, name }), fork({ sandboxId, type: "small" }). The wrapped form the SDK has always accepted, fork({ sandboxId, forkRequest: { type: "small" } }), still works and sends the same request. The flat form needs @boatdev/sdk 1.1.0 or later; on 1.0.x, use the wrapped form.
Browse a stopped sandbox’s filesystem
Snapshot reads never touch the machine, so they work while the sandbox is archived:Waiters and helpers
The package exports first-class waiters and deterministic file/command helper functions:waitForPrompt/waitForPromptDone instead of inferring completion from sandbox.state plus event polling. Use streamPrompt or streamEvents when you need incremental response/tool-call events as work runs.
Streaming responses and tool calls
The SDK now exportsstreamEvents and streamPrompt for response streaming. They use the sandbox v1 events cursor API under the hood, so no separate SSE or WebSocket endpoint is required. response events carry text in event.data.content; streaming partials set event.data.isStreaming; tool-call events are response events with event.data.tools.
streamEvents(sandbox, sandboxId, { type: "prompt,response" }) and stop it with an AbortController.
Operation request types
These exported interfaces wrap method parameters forBoatApi methods.
Model types
TypeScript models use camelCase fields.Errors
Non-2xx responses reject with aResponseError. Read the status and parse the JSON body for the structured Boat error envelope. Redact API keys, Boat secrets, SSH keys, and desktop URLs.