Skip to content

Commands

Commands are asynchronous shell jobs dispatched to a container. Submit a command, receive a job ID, then poll or stream the result.


POST /api/v1/containers/{container_id}/commands

Section titled “POST /api/v1/containers/{container_id}/commands”

Enqueue a new shell command on a running container.

HeaderValueRequired
AuthorizationBearer <token>Yes
Content-Typeapplication/jsonYes
x-csrf-token<csrf_token>Yes, for session auth only

Request Body

FieldTypeRequiredDescription
commandstringYesShell command to execute

Success 200

{
"data": {
"id": "01942cf7-…",
"container_id": "01942cf6-…",
"command": "echo hello",
"status": "queued",
"exit_code": null,
"created_at": "2026-03-28T00:00:00Z"
}
}

Errors

Statuserror.codeReason
400BAD_REQUESTMissing command field
401UNAUTHORIZEDMissing or invalid auth
403CSRF_REJECTEDSession auth missing x-csrf-token
404NOT_FOUNDContainer not found

Fetch the current state and result of a command job.

HeaderValueRequired
AuthorizationBearer <token>Yes

Success 200

{
"data": {
"id": "01942cf7-…",
"container_id": "01942cf6-…",
"command": "echo hello",
"status": "completed",
"exit_code": 0,
"created_at": "2026-03-28T00:00:00Z"
}
}

status values: "queued" | "running" | "completed" | "failed"

Errors

Statuserror.codeReason
401UNAUTHORIZEDMissing or invalid auth
404NOT_FOUNDJob ID not found

Connect over WebSocket to stream stdout/stderr as the command runs:

wss://api.hzel.org/ws/jobs/{job_id}?token=<bearer_token>

The token is passed as a query parameter because browsers cannot set Authorization headers on WebSocket connections.