Exec API
WebSocket Endpoints — Some endpoints in this section use WebSocket for bidirectional communication. The SDK handles the connection protocol automatically.
Query Parameters
Command to execute (can be repeated for command + args)
Session ID to attach to an existing session
Explicit path to executable (defaults to first `cmd` value or `bash`)
Enable TTY mode (default: `false`)
Enable stdin. TTY default: `true`, non-TTY default: `false`
Initial terminal columns (default: `80`)
Initial terminal rows (default: `24`)
Max time to run after disconnect. TTY default: `0` (forever), non-TTY default: `10s`
Environment variables in `KEY=VALUE` format (can be repeated). If set, replaces the default environment.
Responses
Section titled “Responses”| Status | Description |
|---|---|
101 | Switching Protocols - WebSocket connection established |
400 | Bad Request - Invalid WebSocket upgrade or missing parameters |
404 | Not Found - Resource not found |
Client → Server Messages
Section titled “Client → Server Messages”ResizeMessage
Section titled “ResizeMessage”| Field | Type | Description |
|---|---|---|
type | string | (const: "resize") |
cols | uint16 | New column count |
rows | uint16 | New row count |
{ "cols": 180, "rows": 50, "type": "resize"}Server → Client Messages
Section titled “Server → Client Messages”SessionInfoMessage
Section titled “SessionInfoMessage”| Field | Type | Description |
|---|---|---|
type | string | (const: "session_info") |
session_id | int | Process PID |
command | string | Command being executed |
created | int64 | Unix timestamp of session creation |
cols | uint16 | Terminal columns (TTY mode only) |
rows | uint16 | Terminal rows (TTY mode only) |
is_owner | bool | Whether this attachment owns the session |
tty | bool | Whether session is in TTY mode |
{ "cols": 120, "command": "bash", "created": 1767609000, "is_owner": true, "rows": 40, "session_id": 1847, "tty": true, "type": "session_info"}ExitMessage
Section titled “ExitMessage”| Field | Type | Description |
|---|---|---|
type | string | (const: "exit") |
exit_code | int | Process exit code |
{ "exit_code": 0, "type": "exit"}PortNotificationMessage
Section titled “PortNotificationMessage”| Field | Type | Description |
|---|---|---|
type | PortNotificationType | Notification type |
port | int | Port number |
address | string | Proxy URL for accessing the port |
pid | int | Process ID that opened/closed the port |
{ "address": "https://my-sprite.sprites.dev:3000", "pid": 1847, "port": 3000, "type": "port_opened"}Responses
Section titled “Responses”| Status | Description |
|---|---|
200 | Success |
404 | Not Found - Resource not found |
500 | Internal Server Error |
[{ "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"}]Responses
Section titled “Responses”| Status | Description |
|---|---|
101 | Switching Protocols - WebSocket connection established |
400 | Bad Request - Invalid WebSocket upgrade or missing parameters |
404 | Not Found - Resource not found |
Client → Server Messages
Section titled “Client → Server Messages”ResizeMessage
Section titled “ResizeMessage”| Field | Type | Description |
|---|---|---|
type | string | (const: "resize") |
cols | uint16 | New column count |
rows | uint16 | New row count |
{ "cols": 180, "rows": 50, "type": "resize"}Server → Client Messages
Section titled “Server → Client Messages”SessionInfoMessage
Section titled “SessionInfoMessage”| Field | Type | Description |
|---|---|---|
type | string | (const: "session_info") |
session_id | int | Process PID |
command | string | Command being executed |
created | int64 | Unix timestamp of session creation |
cols | uint16 | Terminal columns (TTY mode only) |
rows | uint16 | Terminal rows (TTY mode only) |
is_owner | bool | Whether this attachment owns the session |
tty | bool | Whether session is in TTY mode |
{ "cols": 120, "command": "bash", "created": 1767609000, "is_owner": true, "rows": 40, "session_id": 1847, "tty": true, "type": "session_info"}ExitMessage
Section titled “ExitMessage”| Field | Type | Description |
|---|---|---|
type | string | (const: "exit") |
exit_code | int | Process exit code |
{ "exit_code": 0, "type": "exit"}Query Parameters
Signal to send (default: `SIGTERM`)
Timeout waiting for process to exit (default: `10s`)
Responses
Section titled “Responses”| Status | Description |
|---|---|
200 | Success - Streaming NDJSON response |
404 | Not Found - Resource not found |
500 | Internal Server Error |
Streaming Events
Section titled “Streaming Events”This endpoint returns streaming NDJSON. Each line is one of these event types:
signal
Section titled “signal”| Field | Type | Description |
|---|---|---|
type | string | (const: "signal") |
message | string | Status message |
signal | string | Signal name (e.g., SIGTERM) |
pid | int | Target process ID |
{"message":"Signaling SIGTERM to process group 1847","pid":1847,"signal":"SIGTERM","type":"signal"}timeout
Section titled “timeout”| Field | Type | Description |
|---|---|---|
type | string | (const: "timeout") |
message | string | Status message |
{"message":"Timeout after 10s, sending SIGKILL","type":"timeout"}exited
Section titled “exited”| Field | Type | Description |
|---|---|---|
type | string | (const: "exited") |
message | string | Status message |
{"message":"Process exited","type":"exited"}killed
Section titled “killed”| Field | Type | Description |
|---|---|---|
type | string | (const: "killed") |
message | string | Status message |
{"message":"Process killed","type":"killed"}| Field | Type | Description |
|---|---|---|
type | string | (const: "error") |
message | string | Error message |
{"message":"Warning: process may not have terminated","type":"error"}complete
Section titled “complete”| Field | Type | Description |
|---|---|---|
type | string | (const: "complete") |
exit_code | int | Process exit code |
{"exit_code":0,"type":"complete"}[{ "message": "Signaling SIGTERM to process group 1847", "pid": 1847, "signal": "SIGTERM", "type": "signal"},{ "message": "Process exited", "type": "exited"},{ "exit_code": 0, "type": "complete"}]