Sandboxes
Run a command in a sandbox
Run a command inside a running Runpod sandbox and get its stdout, stderr, and exit code, or start it in the background for longer work.
POST
Runs one command inside the sandbox and returns its output once it completes.
Commands are synchronous and capped at about 4 seconds. A command still running at the cap is stopped and returns
exitCode: null. For longer work, set background: true: the command starts detached and the request returns as soon as it has started. Redirect its output to a file and read the file with a later command.
A sandbox accepts commands only once its container has started, which can lag the RUNNING state by a few seconds. Until then, this endpoint returns 409 with code sandbox_starting. Retry after a short delay.
Each accepted command counts as activity and resets the sandbox’s idle timer.
Path parameters
string
required
The sandbox ID.
Body
string[]
required
The command to run, as an argv array with at least one element. It isn’t interpreted by a shell. To use shell syntax such as pipes, redirects, or
&&, wrap it: ["sh", "-c", "..."].integer
How long the command may run before it’s stopped. The effective limit is currently 4 seconds; longer values are clamped.
boolean
default:"false"
Start the command detached and return as soon as it has started.
output, stdout, and stderr are empty and exitCode is 0 once it has started.Response
string
required
Combined stdout and stderr of the command.
string | null
required
The command’s standard output alone.
null when the host doesn’t report the streams separately.string | null
required
The command’s standard error alone.
null when the host doesn’t report the streams separately.integer | null
required
The command’s exit status,
0 on success. null when the command didn’t exit on its own, for example when it was stopped at the time limit.string | null
The failure reported by the host, if the command exited non-zero or was stopped.
null when the command succeeded.integer
required
Wall-clock time the call took, in milliseconds.
boolean
required
true when the command wrote more than 4 MiB to a stream and the excess was dropped, so the output is incomplete.Errors
Last modified on October 19, 2026