machines

Run a command and stream its output.

Changed on

Runs a command and returns stdout, stderr, and the exit code as Server-Sent Events. Requires the machine:exec scope.

post/v1/machines/{id}/exec/stream

Request

Path parameters

idstring required

Machine id

Request body

backgroundboolean

Run the command detached: spawn it in the background and return its PID immediately. Use for long-lived daemons (dev server, agent runner).

cwdstring nullable
envobject
stdinstring nullable
streamboolean

Stream stdout and stderr as Server-Sent Events instead of buffering the whole run into one JSON body. The response is then text/event-stream, not MachineExecResponse: frames are event: stdout|stderr|error|exit with data: lines, and the terminal exit frame carries {"exitCode": N}. Streamed output is not capped, so this is the right path for long-running or high-volume commands.

timeoutSecondsinteger nullable
userstring nullable

Run as this user: a name from the image or a numeric uid[:gid], overriding the image's USER. Forwarded to the machine's runtime; an older runtime that cannot honour it rejects the request rather than running the command as the wrong account.

Response

Command output as Server-Sent Events, written as it is produced and never truncated. Frames are event: stdout|stderr|error|exit with data: lines; the terminal exit frame carries {"exitCode": N}. Identical to POST /v1/machines/{id}/exec with stream: true — a dedicated path for clients that route by URL rather than by request body.

Changes