Webhooks

Catch

Catch a webhook event and write it to your Postgres. Verified signature, durable Vercel Workflow execution, automatic run tracking. Each catch handler is persisted to `khotan_webhook_handlers` and every execution creates a `khotan_runs` entry with the Workflow run ID for traceability. Tracked in the standard `khotan_runs` table — status, durations, batch counts, create/update/delete/fail tallies, plus a metadata JSON for component-specific stats. Toggle off with --no-runs.

stripe
signed
/api/hook
write
postgres

Install

$ npx khotan add catch <source>

Variants

Named run modes, each independently schedulable with onError/onComplete hooks. The variant name is the mode — flow code branches on ctx.variant. Click a variant above to see the flow change, then select one when triggering.

await khotanData.flow('catch').start({ variant: 'normal' })
import { catchEvent, type CatchContext } from "./catch";
import { db } from "@/db";
import { webhookEvents } from "@/db/schema";
async function stripeCatchWorkflow(ctx: CatchContext) {
"use workflow";
async function persistEvent() {
"use step";
await db.insert(webhookEvents).values({
source: "stripe",
eventType: ctx.eventType,
payload: ctx.event,
receivedAt: new Date(),
});
}
await persistEvent();
}
export const stripeCatch = catchEvent({
name: "stripe-events",
workflow: stripeCatchWorkflow,
});

Documentation

See the full integration guide — schema, generated files, helper API, and configuration — in the Catch docs.