Start a command in a sandbox
Start a long-running command in a Runpod sandbox through the REST API, such as a build or test suite, and read its output later.
Authorizations
Runpod API key authentication. Generate an API key in the Runpod console and send it in the Authorization header as Bearer <api_key>. Keys are scoped to the permissions granted when created; requests may return 403 when a valid key lacks access to the requested resource or action.
Console sessions (Clerk JWTs) act for the signed-in user. To act for a team instead, also send X-Team-Id: <team_id>; it applies only when the user owns or belongs to that team, otherwise the request runs against the user's own account. API keys created inside a team already act for that team and do not need the header.
Path Parameters
Sandbox identifier
Body
Command to run, as an argv array. It is not interpreted by a
shell; wrap in ["sh", "-c", "..."] to use shell syntax. It is
not echoed back in responses, since argv often carries secrets.
1How long the command may run before it is stopped and reported
as timedOut. The command also ends when the sandbox does.
1 <= x <= 864001800
Absolute path of the directory this command runs in. It must start
with /, be at most 4096 bytes and contain no control
characters (U+0000 to U+001F, U+007F to U+009F). Omitted, the command runs in the sandbox's default
working directory.
^/[^\x00-\x1f\x7f-\x9f]*$"/workspace"
Environment variables for this command only, layered over the
sandbox's own environment: a name set here replaces the sandbox's
value for this command. Names must match
^[A-Za-z_][A-Za-z0-9_]*$. At most 128 variables; a name and its
value together at most 128 KiB, within the 1 MiB limit on the
whole request body. A value must not contain a NUL byte. Values
are plain text: {{ RUNPOD_SECRET_* }}
references are not resolved here and reach the command literally.
Values are not logged and are not echoed back.
Response
The command is running.
Command identifier, scoped to its sandbox.
"6f1c2b8e-3d4a-4f7b-9a0e-2c5d8e1f4a7b"
running is the only non-terminal status.
exited: the command ended on its own;exitCodeholds its code.cancelled: stopped byDELETE.timedOut: stopped attimeoutSeconds.failed: never started;errorsays why.unknown: the container went away while it ran, for example because the sandbox stopped. Read the outcome fromstatus, notexitCode.
running, exited, cancelled, timedOut, failed, unknown The command's exit code when status is exited; null otherwise.
0
Why the command failed to start or did not finish normally, if known.
Whether output lines are tagged as stdout or stderr. When
false, the logs streams filter is unavailable.
Bytes of output captured so far.
True once output passed 32 MiB. Further output is dropped; the command keeps running.
True once a cancel has been requested.