Skip to main content
POST
Run a command in the sandbox and return its output.

Authorizations

Authorization
string
header
required

Opaque instabox access token (1 hour). Refresh with /v1/auth/refresh (refresh token valid 30 days, rotates on use).

Path Parameters

id
string
required

Sandbox ID (m_ + 26 lowercase base32 characters) or the sandbox's name (unique among your sandboxes; names never contain _, so the two never collide). Older servers take only the ID and answer 404 for a name.

Pattern: ^(m_[a-z2-7]{26}|[a-z0-9][a-z0-9-]{0,62})$

Body

application/json

Set exactly one of cmd (a shell string) and argv (a program and its arguments, run without a shell); both, neither or an empty argv is 400 bad_request. An empty cmd counts as no cmd, so {"cmd": "", "argv": [...]} runs the argv.

cmd
string
required

Shell command, run with bash -lc. At most 64 KiB, no NUL bytes. Set this or argv; an empty cmd is no cmd.

Required string length: 1 - 65536
argv
string[]

The program and its arguments, run with no shell: each element reaches the program exactly as sent (no expansion of $, * or ~, no word splitting, quotes or redirections; "" is an empty argument). argv[0] must not be empty and is looked up on the login profile's PATH; the login profile, envs and cwd apply as for cmd. A program that is not found exits 127, one that cannot run 126. At most 64 KiB counting each element's length plus one, no NUL bytes. The command sent to the sandbox (envs, cwd and argv, quoted for the shell: about 9 bytes per element plus its text) must also stay under 128 KiB, so many short elements can be 400 bad_request below the 64 KiB cap; send bulk data on stdin. Set this or cmd.

Minimum array length: 1
cwd
string

Working directory (default HOME, /data/home).

Maximum string length: 4096
envs
object

Environment variables exported before the command (after the login profile). Names match ^[A-Za-z_][A-Za-z0-9_]*$.

secretEnvs
object

Direct (delivery env) Secrets of the sandbox's org exported for this command only: variable name -> Secret name. Resolved at exec time, never stored or written into the sandbox; each use is audited by name. A name may not also be in envs; reserved variables are refused. A proxy or missing Secret is 400. Only where GET /v1/me has directSecretRefs; elsewhere 400 (a control host from before secretEnvs would run the command without them).

timeoutSeconds
integer

Default 60, max 600.

Required range: 1 <= x <= 600
stdin
string

Text fed to the command, then EOF. It is a JSON string, so the command reads its UTF-8 bytes: NUL, CR and LF arrive unchanged (escaped as \u0000, \r, \n). At most 1 MiB (1048576 bytes) of UTF-8, counted in bytes, not characters (é is 2): more is 400 bad_request stdin is longer than 1048576 bytes. The schema sets no maxLength here, because maxLength counts characters. JSON cannot carry bytes that are not UTF-8; any in the request body reach the command as U+FFFD (ef bf bd), with no error. For binary input, send it base64-encoded and decode it in the command (base64 -d | ...; up to 768 KiB of binary fits), or write the file first with PUT /v1/machines/{id}/files and redirect it in (cmd < file). The CLI's exec --stdin does that upload itself for input past 1 MiB or not UTF-8, up to 5 GiB.

noHistory
boolean

Leave the command out of the sandbox's history (GET /v1/machines/{id}/history): for a client's own housekeeping commands, such as the CLI's job polls. Does not go with historyCommand.

historyCommand
string

How the command appears in the sandbox's history instead of cmd or argv, for a wrapper that runs something else (the CLI's exec --background). Cut at 4096 bytes like them; no NUL bytes.

Response

The command ran (whatever its exit code).

stdout
string
required

First 1 MiB of standard output.

stderr
string
required

First 1 MiB of standard error.

exitCode
integer
required

Exit status; 128+N if killed by standard signal N, otherwise 255 with signal set; 124 if timed out.

timedOut
boolean
required

The command ran past timeoutSeconds and was killed.

truncated
boolean
required

stdout or stderr was longer than 1 MiB and was cut.

signal
string

The signal that killed the command, as the sandbox named it (absent otherwise).

diskWarning
object

Set when the command failed with No space left on device (read again right after it), or a filesystem was at least 90% full when last read (read in the background after an exec or metrics call, at most once a minute).

invalidUtf8
boolean

stdout or stderr had bytes that are not UTF-8 (binary output), replaced with U+FFFD, so the output is not what the command wrote. Absent when false; also set on a streamed exec's exit event.

oomKilled
boolean

The command exited non-zero and the sandbox's kernel OOM killer killed one of its own processes (the command or a child: its SSH session's cgroup; never another command's process, and each kill is reported once). oomKill says which, when the sandbox named it. Checked only for exit code 137, a signal, or stderr saying a process was killed. False when none was seen, the exec's session scope could not be read, or the sandbox's host or guest agent cannot report kills; a kill whose kernel log record was lost is still true when the session scope's oom_kill count shows it (oomKill absent). Absent from older servers. Also set on a streamed exec's exit event.

oomKill
object

The OOM kill behind oomKilled (the newest, when several).