StateSet Sandbox
Self-hosted Kubernetes sandbox infrastructure for running AI agents and code execution workloads in isolated containers. REST and WebSocket APIs for creating sandboxes, streaming command output, and managing files.Skill Files
| File | URL |
|---|---|
| SKILL.md (this file) | https://doc.stateset.com/stateset-sandbox-skill.md |
API Base URL
| Service | Base URL | Purpose |
|---|---|---|
| Sandbox API | https://api.sandbox.stateset.app/api/v1 | Sandbox management, execution, files |
| WebSocket | wss://api.sandbox.stateset.app/ws | Real-time streaming |
Architecture Overview
- Isolated execution per sandbox pod with resource limits
- REST and WebSocket APIs for command execution and streaming
- File read/write APIs for workspace workflows
- Prebuilt runtime with Node.js, Python, Go, Rust, and CLI tools
- Automatic cleanup with per-sandbox timeouts
- Warm pool support for sub-100ms startup
Agent Registration
AI agents must register to receive an API key for authentication.Register a New Agent
api_key securely. It is only returned once.
Authentication
All API requests require authentication:Quick Start
1. Create a Sandbox
2. Write Files
3. Execute Commands
4. Read Files
5. Stop Sandbox
TypeScript SDK
Installation
Basic Usage
Streaming Execution
Extended SDK (Advanced Features)
Python SDK
Installation
Basic Usage
Running Claude Code Agent
WebSocket API
Connect for real-time streaming:API Reference
Sandbox Lifecycle
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/sandbox/create | Create new sandbox |
| GET | /api/v1/sandbox/:id | Get sandbox details |
| GET | /api/v1/sandbox/:id/status | Get sandbox status |
| GET | /api/v1/sandboxes | List all sandboxes |
| POST | /api/v1/sandbox/:id/stop | Stop sandbox |
| DELETE | /api/v1/sandbox/:id | Delete sandbox |
File Operations
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/sandbox/:id/files | Write files (base64) |
| GET | /api/v1/sandbox/:id/files?path=... | Read file (base64) |
| GET | /api/v1/sandbox/:id/files/download?path=... | Download file (binary) |
Command Execution
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/sandbox/:id/execute | Execute command |
Checkpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/sandbox/:id/checkpoints | Create checkpoint |
| GET | /api/v1/sandbox/:id/checkpoints | List checkpoints |
| POST | /api/v1/sandbox/:id/checkpoints/:cpId/restore | Restore checkpoint |
| POST | /api/v1/sandbox/:id/checkpoints/:cpId/clone | Clone to new sandbox |
| DELETE | /api/v1/sandbox/:id/checkpoints/:cpId | Delete checkpoint |
Artifacts (Cloud Storage)
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/sandbox/:id/artifacts/upload | Upload to S3/GCS/Azure |
| POST | /api/v1/sandbox/:id/artifacts/download | Download from storage |
| GET | /api/v1/artifacts | List artifacts |
| GET | /api/v1/artifacts/:id/url | Get pre-signed URL |
| DELETE | /api/v1/artifacts/:id | Delete artifact |
MCP Servers
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/sandbox/:id/mcp/start | Start MCP server |
| POST | /api/v1/sandbox/:id/mcp/stop | Stop MCP server |
| GET | /api/v1/sandbox/:id/mcp/servers | List running servers |
| GET | /api/v1/sandbox/:id/mcp/presets | List available presets |
Agent Sessions
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/agent-sessions | Create agent session |
| GET | /api/v1/agent-sessions/:id | Get session details |
| POST | /api/v1/agent-sessions/:id/start | Start session |
| POST | /api/v1/agent-sessions/:id/exec | Execute in session |
| POST | /api/v1/agent-sessions/:id/pause | Pause session |
| POST | /api/v1/agent-sessions/:id/resume | Resume session |
| POST | /api/v1/agent-sessions/:id/stop | Stop session |
| GET | /api/v1/agent-sessions/:id/events | Get session events |
API Keys
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/api-keys | Create new API key |
| GET | /api/v1/api-keys | List API keys |
| DELETE | /api/v1/api-keys/:id | Revoke API key |
| POST | /api/v1/api-keys/:id/rotate | Rotate API key |
Webhooks
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/webhooks | Register webhook |
| GET | /api/v1/webhooks | List webhooks |
| PUT | /api/v1/webhooks/:id | Update webhook |
| DELETE | /api/v1/webhooks/:id | Delete webhook |
Tunnels (Port Forwarding)
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/sandbox/:id/tunnels | Create tunnel |
| GET | /api/v1/sandbox/:id/tunnels | List tunnels |
| DELETE | /api/v1/sandbox/:id/tunnels/:tunnelId | Delete tunnel |
Create Sandbox Options
| Field | Type | Default | Description |
|---|---|---|---|
cpus | string | "2" | CPU limit (“1”, “2”, “500m”) |
memory | string | "2Gi" | Memory limit (“1Gi”, “2Gi”, “512Mi”) |
timeout_seconds | number | 600 | Sandbox lifetime (60-86400) |
env | object | {} | Environment variables |
isolation | string | "container" | Isolation level: container, gvisor, microvm |
gpu.count | number | - | GPU count (1-8) |
gpu.type | string | - | GPU type (“nvidia.com/gpu”) |
gpu.memory_gb | number | - | GPU memory (1-256) |
Agent Sessions
Long-running agent sessions with automatic sandbox rotation:pending- Created, not startedrunning- Active executionrotating- Sandbox rotation in progresspaused- Temporarily suspendedcompleted- Successfully finishedfailed- Error occurredcancelled- Manually stopped
MCP Server Integration
Start Model Context Protocol servers inside sandboxes:filesystem- File operationsgithub- GitHub repository accesspostgres- PostgreSQL queriesslack- Slack messagingbrave-search- Web searchpuppeteer- Browser automation
Checkpoints
Save and restore sandbox state:Webhooks
Subscribe to sandbox events:sandbox.created,sandbox.ready,sandbox.stopped,sandbox.error,sandbox.timeoutcommand.started,command.completed,command.failedfile.written,artifact.uploaded,artifact.deletedcheckpoint.created,checkpoint.restored,checkpoint.deletedmcp.started,mcp.stoppedresource.warning,resource.criticalsecurity.alert
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
SANDBOX_IMAGE | - | Docker image for sandbox pods |
DEFAULT_CPUS | "2" | Default CPU limit |
DEFAULT_MEMORY | "2Gi" | Default memory limit |
DEFAULT_TIMEOUT | 600 | Default timeout (seconds) |
MAX_SANDBOXES_PER_ORG | 5 | Max concurrent sandboxes |
WARM_POOL_ENABLED | false | Enable warm pod pool |
WARM_POOL_SIZE | 5 | Warm pool size |
SANDBOX_EXEC_BACKEND | kubectl | Exec backend: kubectl or k8s |
Self-Hosted Deployment
Prerequisites
- Kubernetes cluster (1.24+)
- kubectl configured
- PostgreSQL database
- Redis (optional, for warm pools)
Deploy
Configure Secrets
Security
Container Isolation
- Non-root user: Runs as UID 1001
- Dropped capabilities: ALL capabilities dropped
- Seccomp profile: Enabled by default
- Read-only filesystem: Only /workspace is writable
- Resource limits: CPU, memory, ephemeral storage enforced
Network Isolation
- Egress allowed: HTTPS (443), DNS (53)
- Private ranges blocked: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
- Network policies: Restrictive by default
Authentication
- API Keys: Revocable, organization-scoped
- JWTs: Signed with secret, expiring tokens
- Rate limiting: Per-organization limits
Preinstalled Tools
Each sandbox includes:| Category | Tools |
|---|---|
| Languages | Node.js 20, Python 3.11, Go 1.21, Rust 1.75 |
| Package Managers | npm, yarn, pnpm, pip, cargo |
| Version Control | git, gh (GitHub CLI) |
| Build Tools | make, cmake, gcc, g++ |
| Utilities | curl, wget, jq, ripgrep, fd |
| Containers | Docker CLI (socket mount optional) |
Quick Reference
CLI Commands (curl)
SDK Quick Reference
Ideas to Try
- Register and create your first sandbox
- Run a Claude Code agent to generate and test code
- Set up checkpoints to save and restore work
- Use MCP servers for database or GitHub integration
- Create agent sessions for long-running tasks
- Set up webhooks for real-time notifications
- Deploy self-hosted with warm pools for fast startup
- Use GPU sandboxes for ML workloads
StateSet Sandbox v0.4.0 January 2026