Skip to main content
Accessed via sandbox.exec.

await sandbox.exec.run(command, ...)

Run a command synchronously via sh -c. HTTP API →
command
str
required
Shell command
timeout
int
default:"60"
Timeout in seconds
env
dict[str, str]
Environment variables
cwd
str
Working directory
Returns: ProcessResult
result = await sandbox.exec.run("npm test", cwd="/app")

await sandbox.exec.start(command, ...)

Start a long-running command. Returns the session ID (not a session object). HTTP API →
command
str
required
Command
args
list[str]
Arguments
env
dict[str, str]
Environment variables
cwd
str
Working directory
timeout
int
Timeout in seconds
Returns: str (session ID)
session_id = await sandbox.exec.start("node server.js", cwd="/app")
Python exec.start() returns a session ID string. There are no streaming callbacks, ExecSession object, or max_run_after_disconnect. For streaming, use the WebSocket binary protocol.

await sandbox.exec.list()

List all exec sessions. HTTP API → Returns: list[ExecSessionInfo]

await sandbox.exec.kill(session_id, signal=9)

Kill an exec session. HTTP API → Returns: None

Not Available in Python

  • exec.attach() — reconnect to running session
  • Streaming callbacks (on_stdout, on_stderr, on_exit)
  • ExecSession object with send_stdin() and done
  • max_run_after_disconnect

Types

@dataclass
class ProcessResult:
    exit_code: int
    stdout: str
    stderr: str
@dataclass
class ExecSessionInfo:
    session_id: str
    sandbox_id: str
    command: str
    args: list[str]
    running: bool
    exit_code: int | None
    started_at: str
    attached_clients: int