Skip to content
NorthstarPlatformPricingLogin

Execute command (streaming)

computers.exec.create(strid, ExecCreateParams**kwargs) -> ExecCreateResponse
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.

ParametersExpand Collapse
id: str
command: Optional[str]
cwd: Optional[str]
env: Optional[Dict[str, str]]
timeout_seconds: Optional[int]
ReturnsExpand Collapse
class ExecCreateResponse:
code: Optional[int]

for exit

data: Optional[str]

for stdout/stderr

message: Optional[str]

for error

type: Optional[str]

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

Execute command (streaming)

import os
from tzafon import Lightcone

client = Lightcone(
    api_key=os.environ.get("TZAFON_API_KEY"),  # This is the default and can be omitted
)
for exec in client.computers.exec.create(
    id="id",
):
  print(exec)
Returns Examples