Kagex/Guides
OpenAPI 3Observability & API · 4 min read

sandboxd HTTP/JSON + SSE REST API & OpenAPI 3 Contract Guide

Zero proprietary binary framing between host clients and sandboxd: clean HTTP/1.1 + JSON + SSE over Unix sockets or authenticated loopback TCP.

Contract
docs/openapi.yaml (GET /v1/openapi.yaml)
Unix auth
OS peer credentials (SO_PEERCRED)
TCP auth
Authorization: Bearer $(sandboxd token)
Control sandboxes directly via curl
SOCK="$HOME/Library/Application Support/sandboxd/sandboxd.sock"
curl -s --unix-socket "$SOCK" http://localhost/v1/openapi.yaml | head -n 20
curl -s --unix-socket "$SOCK" -X POST http://localhost/v1/sandboxes \
  -d '{"workspace":{"host_path":"'"$PWD"'"},"template":"auto"}'

Key Engineering Points · OpenAPI, Go/Python SDKs & WAL Storage

All 10 key points →
  • 1sandboxd serves a versioned REST/JSON + SSE API contracted cleanly in docs/openapi.yaml and live at GET /v1/openapi.yaml.
  • 2Public Go SDK in pkg/client requires zero cgo and handles automatic platform discovery across macOS, Linux, and Windows.
  • 3Python integration requires zero third-party pip packages — stdlib http.client + socket AF_UNIX / TCP streams SSE cleanly (docs/examples/python-harness/harness.py).
  • 4Asynchronous executions via wait=false stream chunked stdout, stderr, and final exit payloads over GET /v1/executions/{exec_id}/stream.
  • 5Oversized command logs stay searchable directly via GET /v1/executions/{exec_id}/grep without overflowing LLM token windows.
  • 6Persistence uses pure-Go SQLite (modernc.org/sqlite) in WAL mode with 1 writer and an 8-reader connection pool.

Unix Socket First, Optional Bearer TCP

On macOS and Linux, sandboxd serves directly over an OS-authenticated Unix socket. On Windows (or containers with tcp_listen configured), clients present a Bearer token from sandboxd token.

Streaming Execution Logs Over SSE

Async executions return an exec_id immediately and stream real-time stdout/stderr/exit JSON payloads on GET /v1/executions/{exec_id}/stream.

Inspect this architecture live in 3D

Step through MCP ingress, Ghost Secrets, CoW blades, and run sandboxctl commands interactively in your browser.

Frequently Asked Questions

Fetch GET /v1/openapi.yaml directly from sandboxd or read docs/openapi.yaml in the repository.