All three assume you already have a running
sandbox_id — see the Quickstart if you don’t yet.
Buffered exec
The default choice for scripts, CI, and anything where you just want a result. Synchronous, JSON in and out, no WebSocket. A non-zeroexit_code is still a 200 — check the body, not the HTTP status, to determine command success.
check: true (TypeScript/Go) or check=True (Python) to raise/throw on a non-ok result instead of inspecting exit_code yourself.
For output too large to buffer, a command that runs longer than you want to wait synchronously, or stdin you need to stream interactively, use the SDK’s streaming exec (execStream()/exec_stream()/ExecStream) instead of buffered — see Usage for that variant. It’s still one-shot: the remote process ends when the stream closes, same as buffered exec, just not blocked on a single JSON response.
TTY exec
An HTTP upgrade to a WebSocket for a transient, interactive terminal — one-off, not tracked as a named session. This is what you want for a human typing at a live shell. See Exec and WebSockets for the upgrade and START-frame mechanics; they aren’t repeated here.bonya console is the everyday entry point for this — it’s a shortcut for attaching to (or creating) a managed session named console, so under the hood it actually goes through the managed-session path below rather than raw TTY exec. Reach for raw TTY exec directly from an SDK when you want an interactive terminal without the persistence a named session implies.
Managed sessions
For a command that should keep running after you disconnect — a dev server, a long build — and that you want to list, re-attach to, or kill independently of any single connection, use a managed session. Sessions are named, tracked server-side, and survive the sandbox suspending and resuming. See Sessions for the full field reference.GET .../sessions/{session_name}/attach) — multiple clients can attach to the same session, and a new attach preempts whoever was attached before. Listing sessions never wakes a suspended sandbox; it answers from the state captured at suspend time.