API reference
The public API is a JSON REST API under https://api.kabin.dev/api/v1.
Conventions
- Authentication.
Authorization: Bearer <api-key>on every call. Missing or invalid keys answer401 unauthorized. See API keys. - Envelope. Every response carries
okand a stabletype(for examplesandbox.created). Errors carryok:false,status,code,message,errorandrequestId; see errors. - Ids. Sandboxes are
sbx_<10 characters>. Saved snapshot names match[a-z0-9][a-z0-9-]{0,62}. - Pagination. List routes use a cursor:
limit(1 to 200, default 100),sort(descorasc),cursor. The response carriespageInfo: {nextCursor, hasMore, limit}. An unknown query parameter answers400 invalid_queryand the message lists the accepted ones. Saved snapshots are not paginated. - Idempotency.
POST /sandboxesandPOST /sandboxes/{id}/forkaccept anIdempotency-Keyheader (up to 255 characters). The same key and body replays the first response for 24 hours; the same key with a different body answers409 idempotency_key_reused. - Rate headers. Every response carries
RateLimit-PolicyandRateLimitfor the per-address request policy. Create, resume and fork also report the start windows. A429always carriesRetry-After. - Request bodies. Create, resume and fork accept an empty body. A non-empty body must be valid JSON, otherwise
400 invalid_json.
Routes
| Operation | Route | Result |
|---|---|---|
| Create sandbox | POST /sandboxes | 202 sandbox.created |
| List sandboxes | GET /sandboxes | 200 sandbox.list |
| Get sandbox | GET /sandboxes/{sandboxId} | 200 sandbox.info |
| Update sandbox | PATCH /sandboxes/{sandboxId} | 200 sandbox.info |
| Stop | POST /sandboxes/{sandboxId}/stop | 202 sandbox.stopping |
| Resume | POST /sandboxes/{sandboxId}/resume | 202 sandbox.resuming |
| Fork | POST /sandboxes/{sandboxId}/fork | 202 sandbox.forking |
| Delete | DELETE /sandboxes/{sandboxId} | 202 sandbox.deleting |
| Run a command | POST /sandboxes/{sandboxId}/commands | 200 command.finished / command.started / NDJSON stream |
| Command status | GET /sandboxes/{sandboxId}/commands/{processId} | 200 command.status |
| Stop a command | DELETE /sandboxes/{sandboxId}/commands/{processId} | 200 command.stopped |
| Read file | GET /sandboxes/{sandboxId}/files?path= | 200 file.read |
| Write file | PUT /sandboxes/{sandboxId}/files | 200 file.written |
| Delete file | DELETE /sandboxes/{sandboxId}/files?path= | 200 file.deleted |
| List directory | GET /sandboxes/{sandboxId}/files/list?path= | 200 file.list |
| SSH key | POST /sandboxes/{sandboxId}/sshkey | 200 ssh_key.configured |
| Sandbox usage | GET /sandboxes/{sandboxId}/usage | 200 sandbox.usage |
| Save snapshot | POST /saved-snapshots | 202 snapshot.saved.saving |
| List snapshots | GET /saved-snapshots | 200 snapshot.saved.list |
| Get snapshot | GET /saved-snapshots/{name} | 200 snapshot.saved.info |
| Delete snapshot | DELETE /saved-snapshots/{name} | 200 snapshot.saved.deleted |
| Identity | GET /me | 200 user.info |
| Limits and quotas | GET /limits | 200 limits.info |
| Webhooks | POST /webhooks, GET /webhooks, GET|PATCH|DELETE /webhooks/{webhookId}, POST /webhooks/{webhookId}/rotate | see webhooks |
| API keys | GET /api-keys, POST /api-keys/scoped, DELETE /api-keys/{apiKeyId}, POST /api-keys/{apiKeyId}/rotate, GET /api-keys/{apiKeyId}/usage | see API keys |
Sandboxes
Create
POST /sandboxes returns 202. All fields are optional.
{
"type": "default", // small | default | large
"ttlSeconds": 3600, // 1..2592000, null disables auto-stop
"name": "session-42",
"labels": {"sessionId": "42"}, // up to 20 labels, values up to 256 bytes
"env": {"DATABASE_URL": "..."},// up to 100 variables, 64 KB in total
"files": [{"path": "workspace/.env", "content": "...", "encoding": "utf8"}],
"from": "my-template", // create from a saved snapshot
"count": 5 // 1..1000, only together with "from"
}
Response: {"ok":true,"type":"sandbox.created","status":"provisioning","ttlSeconds":3600,"sandbox":{...}}. With count above 1 the response also carries sandboxes. If the batch does not fit the limits, nothing is created.
The sandbox object
| Field | Meaning |
|---|---|
id, name, state, error | Identity and state (provisioning, ready, archiving, archived, error, cancelled); error says why it stopped or failed. |
type, vcpu, memoryGB, diskGB, billingMultiplier | Size and its VM-time multiplier. |
labels, env | As set at create, resume or fork. |
createdAt, updatedAt, stoppedAt | ISO 8601 timestamps; stoppedAt is null while not stopped. |
ttlSeconds, archiveAfter | Auto-stop setting and the current deadline; null when disabled. |
snapshotAvailable, snapshotCompletedAt, dataExpiredAt | State of the stopped disk. Its data is deleted 14 days after the stop (dataExpiredAt). |
sshEndpoint | host:port of the sandbox SSH server, null while provisioning. |
stop | The last stop operation (status, error), null if none. |
List, get, update
GET /sandboxes accepts state (comma-separated), label=key=value (repeatable), name, namePrefix plus the pagination parameters. PATCH /sandboxes/{id} takes {"name": "...", "ttlSeconds": 3600}; both fields are optional, ttlSeconds: null disables auto-stop.
Stop, resume, fork, delete
- Stop saves the disk and ends metering. Memory and running processes are not saved. Repeating a stop is harmless.
- Resume boots the sandbox from its disk. Optional body
{"type", "ttlSeconds", "env"}; shrinking to a size the data does not fit answers400 type_too_small. While a stop is pending:409 sandbox_stoppingwithRetry-After. - Fork creates a new sandbox from the source's disk state. Optional body
{"type", "ttlSeconds", "env", "labels"}. The response carries the new sandbox. Idempotent withIdempotency-Key. - Delete needs the header
X-Ascii-Confirm-Delete: <sandboxId>, otherwise409 invalid_confirm. Deletion is irreversible and frees the disk.
Commands
POST /sandboxes/{id}/commands with {"command": "npm test", "cwd": "workspace/app", "timeoutSeconds": 600, "detached": false, "stream": false}. cwd is relative to /home/user. A command on a sandbox that is still provisioning waits up to 60 seconds; on a stopped sandbox it resumes it first (and bills the run).
- Synchronous (default):
200 command.finishedwithsuccess,exitCode,signal,oomKilled,stdout,stderr,stdoutTruncated,stderrTruncated,timedOut,cwd,startedAt,finishedAt.timeoutSecondsis 1 to 600, default 30 (400 invalid_timeoutoutside). - Detached (
"detached": true):200 command.startedwith an integerprocessId. PollGET /sandboxes/{id}/commands/{processId}(command.status:statusrunning|exited|lost, output tail up to 8 MiB,stdoutOffset/stderrOffsetquery parameters to continue,tailBytes).DELETEon the same path stops it. - Stream (
"stream": true):200withapplication/x-ndjson. One JSON object per line:{"type":"started"}, then{"type":"stdout"|"stderr","data":"..."}chunks, then exactly one{"type":"exit","exitCode":0,"success":true,"timedOut":false}or{"type":"error",...}.
Files
Paths are absolute or relative to /home/user and must resolve below /home/user or /tmp, otherwise 400 invalid_path. Inline transfers are limited to 5 MiB.
GET /files?path=notes.txt&encoding=utf8returnsfile.readwithpath,encoding(utf8orbase64),size,content. Over 5 MiB:413 file_too_large.PUT /fileswith{"path","content","encoding"}returnsfile.written. The parent directory must exist (create it with a command,mkdir -p).DELETE /files?path=&recursive=truereturnsfile.deleted; a missing path is not an error./home/userand/tmpthemselves are protected.GET /files/list?path=/home/userreturnsfile.listwithfiles[](name,path,isDir,isSymlink,size,mode,modifiedAt) andtruncated.
SSH
POST /sandboxes/{id}/sshkey with {"key": "ssh-ed25519 AAAA..."} appends the public key to the sandbox user and returns ssh_key.configured with sshEndpoint, sshUser and hostKey. Private keys are rejected (400 invalid_key). Remote SSH access is not offered at launch: the returned endpoint is not reachable from the internet. Use commands and files instead.
Usage
GET /sandboxes/{id}/usage?since=&until= returns sandbox.usage: seconds (machine seconds with the size multiplier applied), dollars at list price, running and the effective window. since/until accept ISO 8601 or Unix seconds.
Saved snapshots
POST /saved-snapshotswith{"sandboxId","name"}returns202 snapshot.saved.saving. PollGET /saved-snapshots/{name}untilsnapshot.statusisready(orfailed).GET /saved-snapshotslists newest first (filtersname,namePrefix; no pagination).DELETE /saved-snapshots/{name}returnssnapshot.saved.deleted; sandboxes already created from it are unaffected.- Create from a snapshot with
"from": "<name>". Unknown name:404 snapshot_not_found.
Account
GET /me returns user.info (user.id, login, displayName). GET /limits returns limits.info with canStart, activeSandboxes, maxActiveSandboxes, billingStatus, startLimits, starts (remaining per window), wallet, planIncluded, overagePrices, machineTypes (which sizes you can create now and why not) and more. See limits.
Planned
These parts of the platform are not available on the public API yet and are listed so you can plan around them:
- Organisations and sharing of sandboxes and snapshots
- Environments, secrets and credential profiles
- Signed upload and download URLs and further file operations
- Caller address lookup (
GET /caller-address) and account data-retention settings - Stop and deletion operation polling (
/stops/{id},/deletion-operations/{id})