Skip to content

Exec API

Execute Command

WSS/v1/sprites/{name}/exec

Execute a command in the sprite environment via WebSocket. Commands continue running after disconnect; use `max_run_after_disconnect` to control timeout. Supports TTY and non-TTY modes.

Query Parameters

cmd:string

Command to execute (can be repeated for command + args)

id:optionalstring

Session ID to attach to an existing session

path:optionalstring

Explicit path to executable (defaults to first `cmd` value or `bash`)

tty:optionalbool

Enable TTY mode (default: `false`)

stdin:optionalbool

Enable stdin. TTY default: `true`, non-TTY default: `false`

cols:optionalint

Initial terminal columns (default: `80`)

rows:optionalint

Initial terminal rows (default: `24`)

max_run_after_disconnect:optionalduration

Max time to run after disconnect. TTY default: `0` (forever), non-TTY default: `10s`

env:optionalstring

Environment variables in `KEY=VALUE` format (can be repeated). If set, replaces the default environment.

StatusDescription
101Switching Protocols - WebSocket connection established
400Bad Request - Invalid WebSocket upgrade or missing parameters
404Not Found - Resource not found
FieldTypeDescription
typestring(const: "resize")
colsuint16New column count
rowsuint16New row count
{
"cols": 180,
"rows": 50,
"type": "resize"
}
FieldTypeDescription
typestring(const: "session_info")
session_idintProcess PID
commandstringCommand being executed
createdint64Unix timestamp of session creation
colsuint16Terminal columns (TTY mode only)
rowsuint16Terminal rows (TTY mode only)
is_ownerboolWhether this attachment owns the session
ttyboolWhether session is in TTY mode
{
"cols": 120,
"command": "bash",
"created": 1767609000,
"is_owner": true,
"rows": 40,
"session_id": 1847,
"tty": true,
"type": "session_info"
}
FieldTypeDescription
typestring(const: "exit")
exit_codeintProcess exit code
{
"exit_code": 0,
"type": "exit"
}
FieldTypeDescription
typePortNotificationTypeNotification type
portintPort number
addressstringProxy URL for accessing the port
pidintProcess ID that opened/closed the port
{
"address": "https://my-sprite.sprites.dev:3000",
"pid": 1847,
"port": 3000,
"type": "port_opened"
}
Request

List Exec Sessions

GET/v1/sprites/{name}/exec

List active exec sessions.

StatusDescription
200Success
404Not Found - Resource not found
500Internal Server Error
Request
Response
[
{
"bytes_per_second": 125.5,
"command": "bash",
"created": "2026-01-05T10:30:00Z",
"id": 1847,
"is_active": true,
"last_activity": "2026-01-05T10:35:00Z",
"tty": true,
"workdir": "/home/sprite/myproject"
},
{
"bytes_per_second": 0,
"command": "python -m http.server 8000",
"created": "2026-01-05T09:15:00Z",
"id": 1923,
"is_active": false,
"last_activity": "2026-01-05T09:20:00Z",
"tty": false,
"workdir": "/home/sprite/webapp"
}
]

Attach to Exec Session

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

Attach to an existing exec session via WebSocket.

StatusDescription
101Switching Protocols - WebSocket connection established
400Bad Request - Invalid WebSocket upgrade or missing parameters
404Not Found - Resource not found
FieldTypeDescription
typestring(const: "resize")
colsuint16New column count
rowsuint16New row count
{
"cols": 180,
"rows": 50,
"type": "resize"
}
FieldTypeDescription
typestring(const: "session_info")
session_idintProcess PID
commandstringCommand being executed
createdint64Unix timestamp of session creation
colsuint16Terminal columns (TTY mode only)
rowsuint16Terminal rows (TTY mode only)
is_ownerboolWhether this attachment owns the session
ttyboolWhether session is in TTY mode
{
"cols": 120,
"command": "bash",
"created": 1767609000,
"is_owner": true,
"rows": 40,
"session_id": 1847,
"tty": true,
"type": "session_info"
}
FieldTypeDescription
typestring(const: "exit")
exit_codeintProcess exit code
{
"exit_code": 0,
"type": "exit"
}
Request

Kill Exec Session

POST/v1/sprites/{name}/exec/{session_id}/kill

Kill an exec session by session ID. Returns streaming NDJSON with kill progress.

Query Parameters

signal:optionalstring

Signal to send (default: `SIGTERM`)

timeout:optionalduration

Timeout waiting for process to exit (default: `10s`)

StatusDescription
200Success - Streaming NDJSON response
404Not Found - Resource not found
500Internal Server Error

This endpoint returns streaming NDJSON. Each line is one of these event types:

FieldTypeDescription
typestring(const: "signal")
messagestringStatus message
signalstringSignal name (e.g., SIGTERM)
pidintTarget process ID
{"message":"Signaling SIGTERM to process group 1847","pid":1847,"signal":"SIGTERM","type":"signal"}
FieldTypeDescription
typestring(const: "timeout")
messagestringStatus message
{"message":"Timeout after 10s, sending SIGKILL","type":"timeout"}
FieldTypeDescription
typestring(const: "exited")
messagestringStatus message
{"message":"Process exited","type":"exited"}
FieldTypeDescription
typestring(const: "killed")
messagestringStatus message
{"message":"Process killed","type":"killed"}
FieldTypeDescription
typestring(const: "error")
messagestringError message
{"message":"Warning: process may not have terminated","type":"error"}
FieldTypeDescription
typestring(const: "complete")
exit_codeintProcess exit code
{"exit_code":0,"type":"complete"}
Request
Response
[
{
"message": "Signaling SIGTERM to process group 1847",
"pid": 1847,
"signal": "SIGTERM",
"type": "signal"
},
{
"message": "Process exited",
"type": "exited"
},
{
"exit_code": 0,
"type": "complete"
}
]