Run a command in a sandbox

Starts a command and answers `202` with the exec operation.

POST/v1/sandboxes/{sandbox_id}/exec

Starts a command and answers 202 with the exec operation. Output, input and the exit status travel over the WebSocket at stream_url (GET …/exec/{operation_id}/stream); see ExecStreamServerMessage and ExecStreamClientMessage. A detached process keeps running when the stream closes; the sandbox keeps the last 256 KiB of each output stream, which a new stream replays first. On a sleeping sandbox the call wakes it first. On one still creating or waking it waits until running or the call's deadline, then answers not_ready. Command input (arguments, environment, standard input, typed text) is never logged or stored, and no answer repeats it.

A key with the sandboxes:exec scope.

Request

curl -X POST "https://api.pod.mapier.ai/v1/sandboxes/sbx_3ahrz6dmv29gqy5ckt18fpx4b/exec" \
  -H "Authorization: Bearer $POD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command":"uname -a"}'

Parameters

NameInTypeRequiredWhat it is
sandbox_idpathstringYes
Pod-End-UserheaderstringNoNarrows a project key to one of its end users: the call sees only that end user's sandboxes and usage, any other answering not_found, and a create is labelled with it. An end user of another project, or one that is not there, is not_found; a suspended one refuses creates and wakes (account_restricted).
Idempotency-KeyheaderstringNoMakes a repeat of this call safe for 24 hours.

Body

Give argv or command, not both.

FieldTypeRequiredWhat it is
argvstring[]NoThe program and its arguments, run without a shell.
commandstringNoA command line, run by /bin/sh -c.
envEnvNoEnvironment variables. Never logged, stored or answered back.
cwdstringNoThe working folder. The user's home by default.
userstringNoThe user to run as. The sandbox's default user if not given.
stdinbooleanNoKeep standard input open for stdin messages on the stream. Default false.
ttybooleanNoRun in a terminal. Default false.
timeout_sintegerNo0 means no limit. Default 60. At least 0.
detachedbooleanNoKeep running when the stream closes. Default false.

Answer

202. The command started.

202
{
  "id": "op_3ahrz6dmv29gqy5ckt18fpx4b",
  "sandbox": "sbx_3ahrz6dmv29gqy5ckt18fpx4b",
  "state": "running",
  "detached": false,
  "tty": false,
  "exit_code": null,
  "signal": null,
  "started_at": "2026-11-23T12:00:00.000Z",
  "ended_at": null,
  "stream_url": "wss://api.pod.mapier.ai/v1/sandboxes/sbx_3ahrz6dmv29gqy5ckt18fpx4b/exec/op_3ahrz6dmv29gqy5ckt18fpx4b/stream",
  "oom_killed": false
}
FieldTypeAlwaysWhat it is
idstringYes
sandboxstringYes
state"running" | "exited" | "killed" | "timed_out" | "failed"Yes
detachedbooleanYes
ttybooleanYes
exit_codeinteger | nullYes
signal"TERM" | "KILL" | "INT" | "HUP" | nullYes
started_atstringYesRFC 3339 in UTC with milliseconds, for example 2026-11-23T17:04:05.123Z.
ended_atstring | nullYes
stream_urlstringYesThe address of the stream, always on the host that answered the call. Clients send their key or a stream ticket to it, so they refuse any other address.
oom_killedbooleanNoThe sandbox's out-of-memory killer ended the command: its state is killed with signal KILL (timed_out when the out-of-memory killer ended it after its timeout asked it to stop), or, when a shell ran it, exited with code 137. Sent only once the command has ended and only when true; a missing field means the out-of-memory killer did not end it. A KILL sent through DELETE or a timeout is never reported as the out-of-memory killer's.

Errors

The refusals this call is known for: invalid, guest_unavailable, guest_unresponsive, not_ready, conflict, not_found, in_other_cell. Any call can also answer unauthorized, rate_limited, unavailable or internal; the error list says what each means and when to send the call again.

In the SDKs

ClientCall
TypeScriptsandbox.exec(cmd)
Pythonsandbox.exec(cmd)
mpodmpod sandboxes exec <sandbox> -- <program>