exec
Execute a command inside a VM
Runs command inside the VM. Response shape is determined by the client's Accept header:
- Accept: application/json (default, omitted, or */*): buffered ExecVMResponse — the server collects all output and returns a single JSON object once the command exits. Per-stream output is capped at 4 MiB; overflow bytes are dropped and signalled via stdoutTruncated / stderrTruncated.
- Accept: application/x-ndjson: newline-delimited stream of ExecEvents — zero or more stdout/stderr chunks followed by exactly one terminal exit event. Use this for incremental output (long builds, test runners, live logs). No server-side cap.
Both modes share the same request body. timeoutSec bounds server-side execution; clients should set their own HTTP timeout in addition.
502 responses are transient (the upstream VM host is unreachable or returned an error). The SDK's run() helper does NOT auto-retry these by default: exec is not idempotent, so 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
Response
Command completed. application/json (default) returns a single ExecVMResponse; application/x-ndjson returns an event stream terminated by one exit event.