Kabin

Quickstart

In about five minutes you create a sandbox, run a command in it, write and read a file, and delete it again. The examples use only the standard tooling of each language.

1. Get an API key

  1. Sign up and confirm your e-mail address. During early access new sign-ups may be placed on a waitlist.
  2. Open the dashboard, go to API keys and create a key. Keys look like kbn_t… and are shown once.
  3. Export it: export KABIN_API_KEY=kbn_...

The examples read KABIN_API_KEY and optionally KABIN_API_URL (default https://api.kabin.dev). Never commit keys to a repository.

2. Run it with curl

Needs curl and jq.

Shell

export KABIN_API_KEY="kbn_..."                  # create one in the dashboard under API keys
export KABIN_API_URL="https://api.kabin.dev"
AUTH="Authorization: Bearer $KABIN_API_KEY"

# 1. Check the key
curl -sS "$KABIN_API_URL/api/v1/me" -H "$AUTH"

# 2. Create a sandbox (202, state "provisioning")
SANDBOX_ID=$(curl -sS -X POST "$KABIN_API_URL/api/v1/sandboxes" -H "$AUTH" \
  -H "Content-Type: application/json" \
  -d '{"type":"default","ttlSeconds":3600,"name":"quickstart"}' | jq -r '.sandbox.id')

# 3. Wait until it is ready
until [ "$(curl -sS "$KABIN_API_URL/api/v1/sandboxes/$SANDBOX_ID" -H "$AUTH" | jq -r '.sandbox.state')" = "ready" ]; do sleep 1; done

# 4. Run a command
curl -sS -X POST "$KABIN_API_URL/api/v1/sandboxes/$SANDBOX_ID/commands" -H "$AUTH" \
  -H "Content-Type: application/json" \
  -d '{"command":"echo hello from kabin","timeoutSeconds":30}' | jq '{exitCode, stdout}'

# 5. Write and read a file
curl -sS -X PUT "$KABIN_API_URL/api/v1/sandboxes/$SANDBOX_ID/files" -H "$AUTH" \
  -H "Content-Type: application/json" -d '{"path":"notes.txt","content":"hi","encoding":"utf8"}'
curl -sS "$KABIN_API_URL/api/v1/sandboxes/$SANDBOX_ID/files?path=notes.txt" -H "$AUTH" | jq -r '.content'

# 6. Stop it (disk is kept, billing stops) and delete it
curl -sS -X POST "$KABIN_API_URL/api/v1/sandboxes/$SANDBOX_ID/stop" -H "$AUTH" > /dev/null
curl -sS -X DELETE "$KABIN_API_URL/api/v1/sandboxes/$SANDBOX_ID" -H "$AUTH" \
  -H "X-Ascii-Confirm-Delete: $SANDBOX_ID"

3. Run it with Python

Python 3.9 or newer, standard library only.

Python

import json, os, time, urllib.request

BASE = os.environ.get("KABIN_API_URL", "https://api.kabin.dev") + "/api/v1"
KEY = os.environ["KABIN_API_KEY"]


def call(method, path, body=None, headers=None):
    req = urllib.request.Request(
        BASE + path,
        method=method,
        data=None if body is None else json.dumps(body).encode(),
        headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json", **(headers or {})},
    )
    with urllib.request.urlopen(req) as resp:
        return json.load(resp)


sandbox_id = call("POST", "/sandboxes", {"type": "default", "ttlSeconds": 3600, "name": "quickstart"})["sandbox"]["id"]
while call("GET", f"/sandboxes/{sandbox_id}")["sandbox"]["state"] != "ready":
    time.sleep(1)

result = call("POST", f"/sandboxes/{sandbox_id}/commands", {"command": "echo hello from kabin", "timeoutSeconds": 30})
print(result["exitCode"], result["stdout"], end="")

call("PUT", f"/sandboxes/{sandbox_id}/files", {"path": "notes.txt", "content": "hi", "encoding": "utf8"})
print(call("GET", f"/sandboxes/{sandbox_id}/files?path=notes.txt")["content"])

call("POST", f"/sandboxes/{sandbox_id}/stop", {})
call("DELETE", f"/sandboxes/{sandbox_id}", headers={"X-Ascii-Confirm-Delete": sandbox_id})

4. Run it with TypeScript

Node 22 or newer. Save as quickstart.ts and run it with node quickstart.ts (Node 22.18 and newer strip the types natively; earlier 22.x versions need --experimental-strip-types, or use npx tsx quickstart.ts).

TypeScript

const BASE = (process.env.KABIN_API_URL ?? "https://api.kabin.dev") + "/api/v1";
const KEY = process.env.KABIN_API_KEY!;

async function call(method: string, path: string, body?: unknown, headers: Record<string, string> = {}): Promise<any> {
  const res = await fetch(BASE + path, {
    method,
    headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json", ...headers },
    body: body === undefined ? undefined : JSON.stringify(body),
  });
  const json: any = await res.json();
  if (!json.ok) throw new Error(`${json.status} ${json.code}: ${json.message}`);
  return json;
}

const created = await call("POST", "/sandboxes", { type: "default", ttlSeconds: 3600, name: "quickstart" });
const id: string = created.sandbox.id;
while ((await call("GET", `/sandboxes/${id}`)).sandbox.state !== "ready") {
  await new Promise((r) => setTimeout(r, 1000));
}

const result = await call("POST", `/sandboxes/${id}/commands`, { command: "echo hello from kabin", timeoutSeconds: 30 });
console.log(result.exitCode, result.stdout);

await call("PUT", `/sandboxes/${id}/files`, { path: "notes.txt", content: "hi", encoding: "utf8" });
console.log((await call("GET", `/sandboxes/${id}/files?path=notes.txt`)).content);

await call("POST", `/sandboxes/${id}/stop`, {});
await call("DELETE", `/sandboxes/${id}`, undefined, { "X-Ascii-Confirm-Delete": id });

What just happened

  • POST /api/v1/sandboxes answers 202 while the sandbox is provisioning; poll GET /api/v1/sandboxes/{id} until state is ready. A command sent earlier waits up to 60 seconds for it.
  • Stopping a sandbox saves its disk and stops metering; resume boots it again from that disk. Memory and running processes do not survive a stop.
  • Deleting needs the confirm header X-Ascii-Confirm-Delete: <sandboxId> (a fixed wire name) and cannot be undone.
  • Sandboxes stop automatically after ttlSeconds without activity (default one hour).

Next: the API reference, API keys with narrower scopes, and errors.

These examples were checked against the route table and response shapes of the API server and executed against a local test instance, not against production.