Local API Reference
Control Coding Sandbox programmatically via the REST API running locally on your machine.
Overview
Coding Sandbox exposes a local REST API that lets you manage sandboxes, tunnels, and snapshots programmatically. The API runs on your machine and communicates directly with your local Docker environment — no internet connection required for core operations.
Base URL (default):
http://localhost:8090/apiLocal only
This API runs entirely on your local machine. It is not the same as the cloud API at api.coding-sandbox.dev which handles account and billing. The local API controls your Docker sandboxes directly.
Enabling the API
The local API is disabled by default. To enable it:
- Open Coding Sandbox
- Go to Settings
- Under Local API, toggle Enable API server
- Optionally change the port (default:
8090)
You can also enable it via the CLI:
csb config set api.enabled trueAuthentication
By default, the local API does not require authentication since it only listens on localhost. You can optionally enable API key authentication in Settings:
# With authentication enabled
curl -H "Authorization: Bearer csb_local_your_key" \
http://localhost:8090/api/sandboxesSecurity
If you expose the API to your local network, we recommend enabling authentication. The API key can be generated and rotated in Settings > Local API.
Health & Status
Health Check
GET /api/health{
"status": "ok",
"docker": "connected",
"uptime": 3600
}Version
GET /api/version{
"version": "1.2.0",
"api_version": "v1",
"platform": "darwin-arm64"
}Resource Usage
Returns aggregate resource usage across all running sandboxes.
GET /api/resources{
"cpu_percent": 12.5,
"memory_mb": 1024,
"memory_limit_mb": 8192,
"disk_mb": 4500,
"running_containers": 3
}Sandboxes
List Sandboxes
GET /api/sandboxesReturns all sandboxes with their current status.
{
"data": [
{
"id": "sbx_abc123",
"name": "my-claude-project",
"agent": "claude",
"status": "running",
"cpu_percent": 4.2,
"memory_mb": 256,
"created_at": "2026-01-15T10:30:00Z"
}
]
}Create Sandbox
POST /api/sandboxes{
"name": "my-project",
"agent": "claude",
"tunnel": false,
"ports": ["3000:3000", "8080:8080"],
"env": {
"ANTHROPIC_API_KEY": "sk-..."
}
}Parameters:
name(required) — Unique sandbox nameagent(required) — Agent type:claude,codex,copilot,gemini,kiro,opencode,cagenttunnel— Enable tunnel on creation (default:false)ports— Port mappings inhost:containerformatenv— Environment variables to inject
Get Sandbox
GET /api/sandboxes/:idReturns detailed information about a specific sandbox including resource usage and tunnel status.
Start Sandbox
POST /api/sandboxes/:id/startStarts a stopped sandbox.
Stop Sandbox
POST /api/sandboxes/:id/stopGracefully stops a running sandbox. Use ?force=true to force kill.
Delete Sandbox
DELETE /api/sandboxes/:idThis permanently deletes the sandbox and all its data. This action cannot be undone.
Tunnels
Enable Tunnel
POST /api/sandboxes/:id/tunnelCreates a secure Cloudflare tunnel for the sandbox. Returns the tunnel URL.
{
"tunnel_url": "https://abc123.trycloudflare.com",
"status": "active",
"expires_at": "2026-03-14T16:30:00Z"
}Disable Tunnel
DELETE /api/sandboxes/:id/tunnelDisconnects the tunnel. The sandbox continues running locally.
Get Tunnel Info
GET /api/sandboxes/:id/tunnelReturns the current tunnel status and URL for a sandbox.
Snapshots
List Snapshots
GET /api/sandboxes/:id/snapshots{
"data": [
{
"id": "snap_xyz789",
"name": "before-refactor",
"size_mb": 128,
"created_at": "2026-03-14T10:00:00Z"
}
]
}Create Snapshot
POST /api/sandboxes/:id/snapshots{
"name": "before-refactor"
}Restore Snapshot
POST /api/sandboxes/:id/snapshots/:snapshot_id/restoreRestoring a snapshot replaces the current sandbox state. The sandbox will be restarted.
Delete Snapshot
DELETE /api/sandboxes/:id/snapshots/:snapshot_idError Handling
The API returns standard HTTP status codes. Error responses include a JSON body:
{
"error": {
"code": "sandbox_not_found",
"message": "No sandbox found with the given ID."
}
}Common status codes:
200— Success201— Created400— Bad request (invalid parameters)401— Unauthorized (if authentication is enabled)404— Resource not found409— Conflict (e.g., sandbox name already exists)500— Internal server error503— Docker not available