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
The sandbox identifier. Format:
sbx-<8 chars>.Request Body
The shell command to execute inside the sandbox.Example:
"python3 script.py"When
true, start the command in the background and return immediately with
a PID. Use wait to retrieve the result later.Working directory for the command. Defaults to the envd default (typically
/home/user).Example: "/home/user/project"Additional environment variables scoped to this command only (merged with
sandbox-level
envs).Example: { "DEBUG": "1" }Per-command timeout in seconds.
0 means no timeout.Example: 30.0Unix user to run the command as. Defaults to the envd default user.
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:
Full standard output produced by the command.
Full standard error output produced by the command.
Exit code returned by the process.
0 indicates success.background is true, returns a BackgroundProcess:
Process ID assigned to the background command.
Examples
Foreground command
Response
Background command
Response
Error Responses
| Status | Cause |
|---|---|
400 | Invalid request body |
401 | Missing or invalid API key |
404 | Sandbox not found |
409 | Sandbox is paused — resume it before running commands |
410 | Sandbox has been killed |
502 | envd daemon inside the VM is unreachable |
503 | Sandbox has no VM (no guest IP available) |