Run Command
Command API
Run Command
Execute a command inside a sandbox and return the result synchronously.
POST
Run Command
Executes a shell command inside the sandbox VM via the envd daemon and returns the
full stdout, stderr, and exit code once the process completes.
For long-running processes, pass
When
background: true to start the command without
waiting. The API returns immediately with a PID that you can use with the
wait and kill endpoints.
For real-time output streaming, use the run-stream
endpoint instead.
Path Parameters
string
required
The sandbox identifier. Format:
sbx-<8 chars>.Request Body
string
required
The shell command to execute inside the sandbox.Example:
"python3 script.py"boolean
default:"false"
When
true, start the command in the background and return immediately with
a PID. Use wait to retrieve the result later.string
Working directory for the command. Defaults to the envd default (typically
/home/user).Example: "/home/user/project"object
Additional environment variables scoped to this command only (merged with
sandbox-level
envs).Example: { "DEBUG": "1" }number
Per-command timeout in seconds.
0 means no timeout.Example: 30.0string
Unix user to run the command as. Defaults to the envd default user.
boolean
default:"false"
Reserve a stdin pipe so you can send data later via
send-stdin. Only meaningful when
combined with
background: true.Response
Whenbackground is false (default), returns a CommandResult:
string
Full standard output produced by the command.
string
Full standard error output produced by the command.
integer
Exit code returned by the process.
0 indicates success.background is true, returns a BackgroundProcess:
integer
Process ID assigned to the background command.
Examples
Foreground command
Response
Background command
Response