Skip to Content
Spec

Webhooks

Delivery body, signed headers and outbox message.

Usage

import { signWebhook } from "@dapplelight/signet-lib/webhooks"
import { webhookHeadersSchema } from "@dapplelight/signet-spec/webhooks"

const secret = "whsec_example"
const body = JSON.stringify({ type: "invoice.paid", timestamp: 1_764_000_000, data: {} })

const headers = await signWebhook({ secret, id: "evt_1", body })
webhookHeadersSchema.parse(headers)

Body is { type, timestamp, data }. webhook-signature is one or more space-separated v1,<base64> values. Receivers dedupe on webhook-id.

Signing and verifying are in Client Lib webhooks. Endpoints, retries and the delivery log are in Database webhooks.

API

ExportWhat it does
webhookBodySchemaZod schema for the POST body: type, ISO timestamp, data
webhookHeadersSchemaThe three headers signWebhook returns
webhookOutboxMessageSchemaThe outbox message { id, topic, payload } that queues a delivery
webhookDeliverySchemaHeaders, body and outbox message of one delivery
WebhookBodyz.infer of the body schema
WebhookHeadersz.infer of the headers schema
WebhookOutboxMessagez.infer of the outbox schema
WebhookDeliveryz.infer of the delivery schema
WEBHOOK_TOPIC"signet.webhook", the outbox topic of deliveries