Skip to content
NorthstarPlatformPricingLogin

Execute command (streaming)

POST/computers/{id}/exec

Execute a shell command (desktop sessions only) and stream output back as newline-delimited JSON. Each line is a types.ExecOutput object whose type is one of stdout, stderr, exit, or error. The stream terminates with a single {"type":"exit","code":<int>} line; code -1 indicates timeout or abnormal termination.

Error model: this endpoint always returns HTTP 200 and reports failures (invalid JSON body, missing command, stream-setup failure) as a single {"type":"error","code":"<CODE>","message":"..."} NDJSON line followed by connection close. Clients MUST parse the first line rather than relying on HTTP status codes.

Output is filtered server-side by request ID, so concurrent /exec calls on the same computer don't interleave. Defaults: cwd=/workspace, timeout_seconds=120.

Path ParametersExpand Collapse
id: string
Body ParametersJSONExpand Collapse
command: optional string
cwd: optional string
env: optional map[string]
timeout_seconds: optional number
ReturnsExpand Collapse
code: optional number

for exit

data: optional string

for stdout/stderr

message: optional string

for error

type: optional string

"stdout", "stderr", "exit", "error"

Execute command (streaming)

curl https://api.tzafon.ai/computers/$ID/exec \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $TZAFON_API_KEY" \
    -d '{}'
Returns Examples