Docs / Getting Started

Self-Hosted Onboarding

Register an operator account, create an isolated workspace, mint a kmq_live_ API key, and rotate your workspace webhook_signing_secret.

Updated 2026-11-28~4 min readWorkspace Auth

Once GET /v1/health reports ok, walk through the four-step onboarding flow via the REST API or Web Console to provision a workspace and dispatch your first guaranteed webhook.

1. Register an Operator Account

Create your user account via POST /v1/auth/register. Note that the display name field is fullName (minLength: 8 on password), hashed with Argon2id. The endpoint returns 201 Created with an { accessToken, refreshToken, expiresIn, user } JSON payload:

terminal
curl -s -X POST http://localhost:3000/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "ada@kestrelmq.dev",
    "password": "Str0ngPassw0rd!2026",
    "fullName": "Ada Lovelace"
  }'
201 Created · AuthTokenResponse
{
  "accessToken": "eyJhbGciOiJIUzI1NiIs...",
  "refreshToken": "eyJhbGciOiJIUzI1NiIs...",
  "expiresIn": 900,
  "user": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "ada@kestrelmq.dev",
    "fullName": "Ada Lovelace",
    "createdAt": "2026-11-28T21:00:00.000Z"
  }
}

2. Create a Workspace

Every integration, schema contract, template, routing rule, inbound source, and API key is strictly isolated by workspaceId (UUID). Create a workspace with your accessToken — the creator is automatically assigned the OWNER role:

terminal
curl -s -X POST http://localhost:3000/v1/workspaces \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Commerce",
    "slug": "acme-commerce"
  }'
201 Created · CreatedWorkspaceResponse
{
  "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "name": "Acme Commerce",
  "slug": "acme-commerce",
  "plan": "FREE",
  "webhookSigningSecret": "whsec_9a8f1c4d2e70b36581c9f0e4a2d7b61359c8e4012f7d6a3b8c51e9042d7f6a1b",
  "role": "OWNER",
  "createdAt": "2026-11-28T21:01:00.000Z",
  "updatedAt": "2026-11-28T21:01:00.000Z"
}

3. Issue a kmq_live_ API Key

Event ingestion (POST /v1/events, POST /v1/events/bulk), @kestrelmq/sdk, and the /mcp server authenticate with workspace API keys (kmq_live_<48-hex>). Only OWNER and ADMIN members can mint keys, passing { "name": string }:

terminal
curl -s -X POST http://localhost:3000/v1/workspaces/${WORKSPACE_ID}/api-keys \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Checkout Service"
  }'
201 Created · CreatedApiKeyResponse
{
  "id": "a3b8d1b6-0b3b-4b1a-9c1a-1a2b3c4d5e6f",
  "workspaceId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "name": "Production Checkout Service",
  "apiKey": "kmq_live_9f3a8d12c40e7b65a192f83c04d5e71b9a2c6f48e103b7d5",
  "createdAt": "2026-11-28T21:02:00.000Z"
}

Copy kmq_live_ keys immediately

KestrelMQ stores only the lowercase SHA-256 hash (key_hash) in api_keys. The plaintext apiKey is never stored and cannot be retrieved again after creation.

Publish your first event using @kestrelmq/sdk:

send-first-event.ts
import { KestrelClient } from "@kestrelmq/sdk";

const kestrel = new KestrelClient({
  baseUrl: "http://localhost:3000",
  apiKey: process.env.KESTRELMQ_API_KEY!,
});

const receipt = await kestrel.events.send({
  event: "order.paid",
  payload: {
    orderId: "ord_9001",
    amount: 149.99,
    customer: { email: "ava@acme.io" },
  },
  idempotencyKey: "order-paid-ord_9001",
});
// -> 202 Accepted · eventId: "01937a84-6c21-7d40-8b12-9f4e2c18a301"
terminal
export KESTRELMQ_API_KEY="kmq_live_9f3a8d12..."
npx tsx send-first-event.ts

4. Rotate webhook_signing_secret

Workspace OWNER and ADMIN members can atomically replace the workspace's outbound webhookSigningSecret (whsec_<64-hex>) via POST /v1/workspaces/:id/rotate-secret (200 OK, no request body required):

terminal
curl -s -X POST http://localhost:3000/v1/workspaces/${WORKSPACE_ID}/rotate-secret \
  -H "Authorization: Bearer ${ACCESS_TOKEN}"
200 OK · RotatedWebhookSecretResponse
{
  "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "webhookSigningSecret": "whsec_4e81b09c2d73f6a5180c9e4b3d27a6f190c5e28d4b7a31f68e9c02b5d17a4e6c",
  "updatedAt": "2026-11-28T21:15:00.000Z"
}

Per-integration vs. workspace signing secrets

Rotation updates workspaces.webhook_signing_secret for subsequent outbound attempts and keeps the previous secret for a grace window (gracePeriodHours, default 24 via SECRET_ROTATION_GRACE_HOURS; 0 invalidates it immediately). During the window KestrelMQ sends X-KestrelMQ-Signature: v1=<new_hex>,v1=<old_hex>, so receivers that check every v1= signature rotate with zero downtime. If you need independent secrets per destination during a staggered consumer migration, set credentials.signingSecret on individual CUSTOM_WEBHOOK integrations (which are sealed at rest with AES-256-GCM).