Skip to main content

What you can do

Everything is a flat method on Bonya or Sandbox. There is no client.sandboxes.create(...) namespace to navigate.
Bonya also has convenience methods that take a sandbox id instead of a Sandbox handle, such as client.createSession(sandboxId, name, cmd) and client.createPreview(sandboxId, port). Each fetches the sandbox first, so prefer calling on sandbox when you already hold one.

Create sandboxes

If create exhausts its deadline the SDK throws SandboxCreationTimeoutError, which carries the idempotencyKey so you can retry the same creation instead of starting a second sandbox.

Get, list, and find by name

sandbox.state is one of creating, running, cooling, warm, cold, waking, failed, deleting, deleted or lost.

Run commands

Streaming exec

The process dies when the stream closes. For anything that must outlive your connection, use a session.

Persistent sessions

Session names match ^[a-z][a-z0-9-]{0,31}$. A session keeps running after you detach and replays what it produced while nobody was attached.

Files

Previews

Grant tokens are shown once, in the response that creates them.

Lifecycle, snapshots, and forks

Jobs

runJob waits for the result; startJob returns immediately. Use getJobRun(id), listJobRuns() and cancelJobRun(id) to track runs.

Schedules

A schedule uses exactly one of cronExpressions, intervalSeconds or runAtUnixNanos.

Templates

Registry connections, secrets, and secret sets

Secret and secret-set values are write-only; the API never returns them. Reference secret sets by name.

Organizations

The precedence is the constructor option, then BONYA_ORGANIZATION_ID, then your personal organization. Creating organizations, members, invites and API keys is done in the dashboard, not through the SDK.

Errors

Every error extends BonyaError (with sandboxId, idempotencyKey, code). Branch on the class: AuthenticationError, SandboxNotFoundError, SandboxCreationTimeoutError, ExecFailedError, TimeoutError, NoCapacityError, RateLimitedError, OutcomeUnknownError, RemoteFileNotFoundError, and so on. API keys and capability tokens are redacted from error messages.
Server errors are RFC 9457 problem+json; see Errors.