Run a command and wait for it to finish
Runs a command to completion and returns its output in a single
response, retained up to a server-side cap (see truncated). For live
or unbounded output use POST /exec/stream (Server-Sent Events) or
GET /exec/connect (WebSocket). A non-zero exit code is returned in
the body, not as an HTTP error. The sandbox must be running; a
paused sandbox returns 503. Activate it first with
POST /sandboxes/{sandbox_id}/activate (the SDKs do this
automatically).
Authorizations
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
Command to execute. Wrapped in /bin/sh -c unless args is provided.
1If provided, command is used as the binary and args as arguments (no shell wrapping).
Environment variables for the command.
Working directory (default /home/user).
Timeout in seconds.
Response
The command finished; output and exit code.
Output of a command run to completion via POST /exec.
Standard output; see truncated.
Standard error; see truncated.
Process exit code. A non-zero value is returned, not raised.
Present and true when combined stdout/stderr exceeded the server-side retention cap (currently 8 MiB) and the tail was dropped; a notice explaining the cut is also appended to stderr. Use POST /exec/stream for unbounded output.