Execute Command
Shell command to execute
Working directory for command execution (defaults to sandbox working directory)
Whether to run command in detached mode.
false: Streams output in real-time (foreground)true: Runs in background, retrieve logs via/command/{id}/logs
Maximum allowed execution time in milliseconds before the command is forcefully terminated by the server. If omitted, the server will not enforce any timeout.
Event type:
init, status, stdout, stderr, execution_complete, error, pingOutput text for stdout/stderr events
When the event was generated (Unix milliseconds)
Total execution duration in milliseconds (on completion)
Get Command Status
Command ID returned by RunCommand (from the
init event)Command ID
Original command content
Whether the command is still running
Exit code if the command has finished (null if still running)
Error message if the command failed
Start time in RFC3339 format
Finish time in RFC3339 format (null if still running)
Get Background Command Logs
This endpoint supports incremental reads similar to a file seek. Pass a starting line via the
cursor parameter to fetch output after that line and receive the latest tail cursor for the next poll.Command ID returned by RunCommand
Optional 0-based line cursor (behaves like a file seek). When provided, only stdout/stderr lines after this line are returned. If omitted, the full log is returned.
Plain text output containing stdout and stderr combined
Highest available 0-based line index after applying the request cursor. Use this value as the next cursor for incremental reads.
Interrupt Command Execution
Session ID of the execution context to interrupt
Foreground vs Background Mode
Foreground Mode (background: false)
- Output is streamed in real-time via SSE
- Connection remains open until command completes
- Ideal for short-running commands and interactive use
- Example:
ls,grep,find
Background Mode (background: true)
- Command runs in detached mode
- Returns immediately with command ID
- Use
/command/status/{id}to check status - Use
/command/{id}/logsto retrieve output - Ideal for long-running processes and servers
- Example:
python server.py,npm run dev
Timeout Handling
When you specify atimeout (in milliseconds), the server will automatically terminate the command if it exceeds the specified duration:
- The process receives a termination signal
- The status will show
exit_code: nulland an error message - For foreground commands, you’ll receive an
errorevent in the stream