Skip to main content
POST
Run a command and stream output over SSE

Authorizations

X-Access-Token
string
header
required

Per-sandbox token returned by create, resume, and activate. Grants access to a single sandbox's files and commands. Distinct from the team X-API-Key.

Body

application/json
command
string
required

Command to execute. Wrapped in /bin/sh -c unless args is provided.

Minimum string length: 1
args
string[]

If provided, command is used as the binary and args as arguments (no shell wrapping).

env
object

Environment variables for the command.

working_dir
string

Working directory (default /home/user).

timeout_s
integer
default:30

Timeout in seconds.

Response

A Server-Sent Events stream of output and lifecycle events.

One Server-Sent Event from POST /exec/stream, delivered as a data: line carrying this JSON object. Output events carry stdout or stderr (each with a timestamp); the terminal event carries finished: true with exit_code, or error and code if the command could not be run. The stream may also include SSE comment keepalive lines (: keepalive), which carry no data.

timestamp
string<date-time>

RFC 3339 time the event was emitted (output and terminal events).

stdout
string

A chunk of standard output.

stderr
string

A chunk of standard error.

finished
boolean

Present and true on the terminal event.

exit_code
integer

Process exit code, on the terminal event.

error
string

Error message if the command could not be run.

code
string

Error code accompanying error (e.g. bad_request, exec_failed).