DOCS

API reference

The REST + WebSocket API behind qbox. The SDK and CLI are thin wrappers over these endpoints.

Everything in qbox is driven by an HTTP API served by the control plane. The Python SDK and CLI wrap these endpoints — use them directly when you need a language without an SDK.

Base URL & authentication

All paths are under /v1 on your control-plane origin (same host as the dashboard). Authenticate machine clients with an API key as a bearer token (create one under API Keys in the dashboard):

export QBOX=https://qbox.your-company.internal
export TOKEN=qbox_...

curl -H "Authorization: Bearer $TOKEN" "$QBOX/v1/sandboxes"

The dashboard itself uses a session cookie; API keys are for programmatic access. GET /healthz is unauthenticated for liveness checks.

Sandboxes

MethodPathDescription
POST/v1/sandboxesSpawn a sandbox from a template.
GET/v1/sandboxesList sandboxes.
GET/v1/sandboxes/{id}Get one sandbox.
DELETE/v1/sandboxes/{id}Terminate a sandbox.
POST/v1/sandboxes/{id}/timeoutExtend the auto-kill timeout (resets the timer).

A sandbox is auto-killed 5 minutes after spawn by default (e2b parity); pass timeoutSeconds on spawn to override, 0 to disable, or call the timeout endpoint / set_timeout to extend a running sandbox. | GET | /v1/sandboxes/{id}/logs | Fetch sandbox logs. |

# spawn
curl -X POST "$QBOX/v1/sandboxes" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"templateId":"tpl_python312"}'
# → { "id": "sb_7a3f", "status": "booting" }

Exec & processes

MethodPathDescription
POST/v1/sandboxes/{id}/execRun a command, wait, return stdout/stderr/exit code.
POST/v1/sandboxes/{id}/commandsStart a background process.
GET/v1/sandboxes/{id}/commandsList processes.
GET/v1/sandboxes/{id}/commands/{pid}Process status.
GET/v1/sandboxes/{id}/commands/{pid}/logsProcess logs.
DELETE/v1/sandboxes/{id}/commands/{pid}Kill a process.
curl -X POST "$QBOX/v1/sandboxes/sb_7a3f/exec" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"cmd":"python","args":["-c","print(1+1)"]}'
# → { "stdout": "2\n", "stderr": "", "exitCode": 0 }

Files

MethodPathDescription
GET/v1/sandboxes/{id}/files?path=List a directory.
GET/v1/sandboxes/{id}/file?path=Read a file.
PUT/v1/sandboxes/{id}/file?path=Write a file.
DELETE/v1/sandboxes/{id}/file?path=Remove a file.
GET/v1/sandboxes/{id}/stat?path=Stat a path.
GET/v1/sandboxes/{id}/download?path=Download a file (stream).
POST/v1/sandboxes/{id}/files/mkdirCreate a directory.
POST/v1/sandboxes/{id}/files/renameRename/move a path.

Code interpreter

MethodPathDescription
POST/v1/sandboxes/{id}/code-executeRun code in a stateful kernel.
GET/v1/sandboxes/{id}/code-languagesList available languages.
GET/v1/sandboxes/{id}/code-contextsList kernel contexts.
POST/v1/sandboxes/{id}/code-contextsCreate a context.
POST/v1/sandboxes/{id}/code-contexts/{contextId}/restartRestart a context.
DELETE/v1/sandboxes/{id}/code-contexts/{contextId}Remove a context.

Interactive shell (WebSocket)

GET /v1/sandboxes/{id}/shell upgrades to a WebSocket carrying an interactive PTY (for templates with SSH enabled). The dashboard Shell tab and the SDK’s shell() use this.

Templates

MethodPathDescription
GET/v1/templatesList templates.
GET/v1/templates/{id}Get one template.
GET/v1/templates/{id}/build-logFetch the build log.
POST/v1/templatesCreate + build a template from an OCI image.

Hosts

MethodPathDescription
GET/v1/hostsList hosts and their live utilization.
GET/v1/hosts/{id}Get one host.

API keys & audit

MethodPathDescription
GET/v1/api-keysList API keys.
POST/v1/api-keysCreate a key (the secret is returned once).
POST/v1/api-keys/{id}/revokeRevoke a key.
GET/v1/auditQuery the audit log.

Errors

Errors return a JSON body { "error": { "code": "...", "message": "..." } } with a matching HTTP status — 400 validation, 401/403 auth, 404 not found, 409 conflict, 422 policy/feature, 429 rate limited, 503 no capacity. Clients should retry only 429/503.