Skip to content

Execution API

Execute commands on sprites remotely via WebSocket.

List Sessions

GET /v1/sprites/{name}/exec

Lists active execution sessions that can be reattached.

Response

json
[
  {
    "id": "abc123",
    "cmd": ["node", "app.js"],
    "started_at": "2025-01-01T00:00:00Z",
    "active": true
  }
]

Execute Command

GET /v1/sprites/{name}/exec?cmd=<command>&arg=<arg1>&arg=<arg2>

WebSocket upgrade required. Initiates command execution.

Query Parameters

ParamDescription
cmdCommand to run
argCommand argument (repeat for multiple)
dirWorking directory
envEnvironment variable KEY=value (repeat for multiple)
ttyEnable TTY mode (true/false)
rowsTTY rows (with tty=true)
colsTTY columns (with tty=true)

Example

GET /v1/sprites/my-sprite/exec?cmd=node&arg=server.js&dir=/home/sprite/app
GET /v1/sprites/my-sprite/exec?cmd=bash&tty=true&rows=24&cols=80

WebSocket Messages

From server:

json
{"type": "stdout", "data": "Server started"}
{"type": "stderr", "data": "Warning: ..."}
{"type": "exit", "exit_code": 0}
TypeDescription
infoInformational message
stdoutStandard output
stderrStandard error
errorError message
exitProcess exited (includes exit_code)

To server (TTY mode):

json
{"type": "stdin", "data": "ls -la\n"}
{"type": "resize", "rows": 30, "cols": 120}

Reattach Session

GET /v1/sprites/{name}/exec/{session_id}

WebSocket upgrade required. Reattaches to an existing session.


Port Forwarding

GET /v1/sprites/{name}/proxy?local=<port>&remote=<port>

WebSocket upgrade required. Forwards traffic between local and remote ports.

Query Parameters

ParamDescription
localLocal port
remoteRemote port on sprite

Port Notifications

When a port opens on the sprite:

json
{"type": "port_open", "port": 3000, "pid": 1234}

When closed:

json
{"type": "port_close", "port": 3000}