Kabin

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 answer 401 unauthorized. See API keys.
  • Envelope. Every response carries ok and a stable type (for example sandbox.created). Errors carry ok:false, status, code, message, error and requestId; 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 (desc or asc), cursor. The response carries pageInfo: {nextCursor, hasMore, limit}. An unknown query parameter answers 400 invalid_query and the message lists the accepted ones. Saved snapshots are not paginated.
  • Idempotency. POST /sandboxes and POST /sandboxes/{id}/fork accept an Idempotency-Key header (up to 255 characters). The same key and body replays the first response for 24 hours; the same key with a different body answers 409 idempotency_key_reused.
  • Rate headers. Every response carries RateLimit-Policy and RateLimit for the per-address request policy. Create, resume and fork also report the start windows. A 429 always carries Retry-After.
  • Request bodies. Create, resume and fork accept an empty body. A non-empty body must be valid JSON, otherwise 400 invalid_json.

Routes

Public routes (all under /api/v1)
OperationRouteResult
Create sandboxPOST /sandboxes202 sandbox.created
List sandboxesGET /sandboxes200 sandbox.list
Get sandboxGET /sandboxes/{sandboxId}200 sandbox.info
Update sandboxPATCH /sandboxes/{sandboxId}200 sandbox.info
StopPOST /sandboxes/{sandboxId}/stop202 sandbox.stopping
ResumePOST /sandboxes/{sandboxId}/resume202 sandbox.resuming
ForkPOST /sandboxes/{sandboxId}/fork202 sandbox.forking
DeleteDELETE /sandboxes/{sandboxId}202 sandbox.deleting
Run a commandPOST /sandboxes/{sandboxId}/commands200 command.finished / command.started / NDJSON stream
Command statusGET /sandboxes/{sandboxId}/commands/{processId}200 command.status
Stop a commandDELETE /sandboxes/{sandboxId}/commands/{processId}200 command.stopped
Read fileGET /sandboxes/{sandboxId}/files?path=200 file.read
Write filePUT /sandboxes/{sandboxId}/files200 file.written
Delete fileDELETE /sandboxes/{sandboxId}/files?path=200 file.deleted
List directoryGET /sandboxes/{sandboxId}/files/list?path=200 file.list
SSH keyPOST /sandboxes/{sandboxId}/sshkey200 ssh_key.configured
Sandbox usageGET /sandboxes/{sandboxId}/usage200 sandbox.usage
Save snapshotPOST /saved-snapshots202 snapshot.saved.saving
List snapshotsGET /saved-snapshots200 snapshot.saved.list
Get snapshotGET /saved-snapshots/{name}200 snapshot.saved.info
Delete snapshotDELETE /saved-snapshots/{name}200 snapshot.saved.deleted
IdentityGET /me200 user.info
Limits and quotasGET /limits200 limits.info
WebhooksPOST /webhooks, GET /webhooks, GET|PATCH|DELETE /webhooks/{webhookId}, POST /webhooks/{webhookId}/rotatesee webhooks
API keysGET /api-keys, POST /api-keys/scoped, DELETE /api-keys/{apiKeyId}, POST /api-keys/{apiKeyId}/rotate, GET /api-keys/{apiKeyId}/usagesee 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

Sandbox fields
FieldMeaning
id, name, state, errorIdentity and state (provisioning, ready, archiving, archived, error, cancelled); error says why it stopped or failed.
type, vcpu, memoryGB, diskGB, billingMultiplierSize and its VM-time multiplier.
labels, envAs set at create, resume or fork.
createdAt, updatedAt, stoppedAtISO 8601 timestamps; stoppedAt is null while not stopped.
ttlSeconds, archiveAfterAuto-stop setting and the current deadline; null when disabled.
snapshotAvailable, snapshotCompletedAt, dataExpiredAtState of the stopped disk. Its data is deleted 14 days after the stop (dataExpiredAt).
sshEndpointhost:port of the sandbox SSH server, null while provisioning.
stopThe 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 answers 400 type_too_small. While a stop is pending: 409 sandbox_stopping with Retry-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 with Idempotency-Key.
  • Delete needs the header X-Ascii-Confirm-Delete: <sandboxId>, otherwise 409 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.finished with success, exitCode, signal, oomKilled, stdout, stderr, stdoutTruncated, stderrTruncated, timedOut, cwd, startedAt, finishedAt. timeoutSeconds is 1 to 600, default 30 (400 invalid_timeout outside).
  • Detached ("detached": true): 200 command.started with an integer processId. Poll GET /sandboxes/{id}/commands/{processId} (command.status: status running|exited|lost, output tail up to 8 MiB, stdoutOffset/stderrOffset query parameters to continue, tailBytes). DELETE on the same path stops it.
  • Stream ("stream": true): 200 with application/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=utf8 returns file.read with path, encoding (utf8 or base64), size, content. Over 5 MiB: 413 file_too_large.
  • PUT /files with {"path","content","encoding"} returns file.written. The parent directory must exist (create it with a command, mkdir -p).
  • DELETE /files?path=&recursive=true returns file.deleted; a missing path is not an error. /home/user and /tmp themselves are protected.
  • GET /files/list?path=/home/user returns file.list with files[] (name, path, isDir, isSymlink, size, mode, modifiedAt) and truncated.

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-snapshots with {"sandboxId","name"} returns 202 snapshot.saved.saving. Poll GET /saved-snapshots/{name} until snapshot.status is ready (or failed).
  • GET /saved-snapshots lists newest first (filters name, namePrefix; no pagination).
  • DELETE /saved-snapshots/{name} returns snapshot.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})