Skip to main content

What you can do

Everything is a flat method on Bonya or Sandbox.
Bonya also has convenience methods that take a sandbox id, such as client.create_session(sandbox_id, name, cmd). Each fetches the sandbox first, so prefer calling on sandbox when you already hold one.

Create sandboxes

Sandbox is a context manager that deletes the sandbox on exit. If create exhausts its deadline the SDK raises SandboxCreationTimeoutError, which carries the idempotency_key so you can retry the same creation.

Get, list, and find by name

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}$.

Files

Previews

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

Lifecycle, snapshots, and forks

Jobs

run_job waits for the result; start_job returns immediately. Use get_job_run(id), list_job_runs() and cancel_job_run(id) to track runs.

Schedules

A schedule uses exactly one of cron_expressions, interval_seconds or run_at_unix_nanos.

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 argument, 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 sandbox_id, idempotency_key, code). Catch the class you care about: 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.