Execute a command in a sandbox
run_commandExecute commands in a boat.dev sandbox synchronously or in the background, with optional live streaming and configurable timeouts for automation and debugging.
Instructions
Execute a command in a sandbox. Runs the command synchronously by default (timeout configurable via timeoutSeconds, 600s cap). With detached: true the command starts in the background and a process id is returned immediately; poll /sandboxes/{sandboxId}/commands/{processId} for status and logs. With stream: true the output arrives as the command writes it, as newline-delimited JSON (application/x-ndjson): {"type":"started"}, then {"type":"stdout"|"stderr","data":"..."} per chunk, and last {"type":"exit",...} (the synchronous result without stdout/stderr) or {"type":"error","error":"...","message":"..."}. Returns 400 invalid_timeout when timeoutSeconds is not an integer in 1-600. A command sent while the sandbox is still starting (right after a resume) waits up to 60s for it to be ready instead of failing; 409 boat_starting (retryable) is returned only if it is still not ready by then. A sandbox that is not starting (error, stopped) returns 409 sandbox_not_ready with retryable: false and its state at once: resume or recover it first. Command execution is never retried automatically: a 502 boat_direct_failed means the command may already be running on the sandbox. Every command and its output are kept 7 days in the command history (/sandboxes/{sandboxId}/command-history), readable while the sandbox is stopped.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sandboxId": "<sandboxId>",
"command": "<command>"
},
"name": "run_command"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Relative working directory inside the sandbox work directory. | |
| stream | No | Stream the output as the command writes it: the response is newline-delimited JSON (application/x-ndjson), one CommandStreamFrame per line. Ignored with detached. | |
| command | Yes | ||
| detached | No | Start the command in the background and return a process id immediately instead of waiting for it to finish. Output goes to a log file on the sandbox; poll the status endpoint for it. | |
| sandboxId | Yes | Public Sandbox id returned by create/list/get sandbox calls. | |
| timeoutSeconds | No | Command timeout in seconds. Values outside 1-600 are rejected with a 400 invalid_timeout error. |