Kabin

Webhooks

Kabin calls your HTTPS endpoint when a sandbox changes state, so you do not have to poll.

Endpoints

Webhook routes (under /api/v1, unrestricted key required)
RoutePurpose
POST /webhooks201 webhook.created. Body {name?, url, events[]}. The signing secret (whsec_...) is returned once.
GET /webhooks, GET /webhooks/{webhookId}List or read; secrets are never returned
PATCH /webhooks/{webhookId}Change name, URL or events; the secret stays
DELETE /webhooks/{webhookId}Delete; queued deliveries are dropped
POST /webhooks/{webhookId}/rotateNew secret, returned once

Shell

curl -sS -X POST "$KABIN_API_URL/api/v1/webhooks" \
  -H "Authorization: Bearer $KABIN_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"ci","url":"https://example.com/kabin-hook","events":["sandbox.ready","sandbox.archived"]}'
  • The URL must be https on port 443 and resolve to public addresses only. Redirects are not followed. Up to 10 distinct URLs per account; events needs at least one entry.
  • Events: sandbox.ready, sandbox.error, sandbox.archived, sandbox.hydrated (right after a resume completes), sandbox.degraded, sandbox.recovered. The last two are reserved and not emitted at launch.

Payload

JSON

{
  "id": "evt_9f2c1a7e5b3d4c60",
  "type": "sandbox.ready",
  "createdAt": "2026-11-28T12:00:00.000Z",
  "data": {
    "sandbox": { "id": "sbx_23456789ab", "name": "worker" },
    "previousState": "provisioning",
    "state": "ready"
  }
}

The top-level id is the deduplication key. previousState and state are present on ready, error and archived.

Headers

Delivery headers
HeaderValue
X-Ascii-EventEvent type, for example sandbox.ready
X-Ascii-DeliveryThe event id, stable across retries
X-Ascii-TimestampUnix seconds of this attempt
X-Ascii-Signaturev1= plus hex HMAC-SHA256
X-Ascii-AttemptAttempt number, from 1

These header names are fixed wire names.

Verify the signature

The signature is HMAC_SHA256(secret, eventId + "." + timestamp + "." + rawBody), with the whole whsec_... string as the key. Compute it over the raw bytes before parsing JSON, compare in constant time and reject timestamps more than 300 seconds off.

Python

import hashlib, hmac, time


def verify(secret: str, headers: dict, raw_body: bytes, tolerance: int = 300) -> bool:
    """headers: the request headers with lower-case names; raw_body: the bytes as received."""
    event_id = headers["x-ascii-delivery"]
    timestamp = headers["x-ascii-timestamp"]
    if abs(time.time() - int(timestamp)) > tolerance:
        return False
    signed = f"{event_id}.{timestamp}.".encode() + raw_body
    expected = "v1=" + hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, headers["x-ascii-signature"])

TypeScript

import { createHmac, timingSafeEqual } from "node:crypto";

export function verify(secret: string, headers: Record<string, string>, rawBody: Buffer, toleranceSeconds = 300): boolean {
  const eventId = headers["x-ascii-delivery"];
  const timestamp = headers["x-ascii-timestamp"];
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > toleranceSeconds) return false;
  const signed = Buffer.concat([Buffer.from(`${eventId}.${timestamp}.`), rawBody]);
  const expected = Buffer.from("v1=" + createHmac("sha256", secret).update(signed).digest("hex"));
  const given = Buffer.from(headers["x-ascii-signature"] ?? "");
  return expected.length === given.length && timingSafeEqual(expected, given);
}

Delivery and retries

  • At least once. A 2xx within 5 seconds counts as delivered; anything else is retried with exponential backoff, up to 8 attempts. Delivery records are kept 30 days.
  • Events can arrive out of order and more than once. Deduplicate on the event id.
  • After a rotation accept the old and the new secret briefly: an attempt already in flight can still carry the old signature.