exec

Execute a command inside a VM

Runs a command via the VM's guest agent and returns stdout, stderr, exit code, and timing. timeoutSec bounds server-side execution; clients should set their own HTTP timeout in addition.

502 responses are transient (worker unreachable, worker-side timeout, or worker 5xx — all collapsed into 502 at the scheduler). The SDK's run() helper does NOT auto-retry these by default: exec is not idempotent — if a 502 hides a successful exec, a retry may run the command twice. Callers opt in with max_retries=N per call.

post/v1/vms/{id}/exec

Request body

commandstring[] required

Argv-style command. First element must be non-empty. For shell strings, wrap as ["sh", "-c", "<string>"].

timeoutSecinteger

Server-side execution timeout in seconds. Must be positive when provided; omit to use the server default.

Response

Command result

exitCodeinteger required
stdoutstring required
stderrstring required
timedOutboolean required
stdoutTruncatedboolean required
stderrTruncatedboolean required
durationMsinteger required

Changes