Outgoing webhooks let your customers receive product events in their own systems. Codapult includes subscription management, HMAC signing, delivery records, retries, and dead-letter replay.
Key files
| File | Purpose |
|---|---|
src/lib/outgoing-webhooks/index.ts | Subscription, dispatch, retry, and replay helpers |
src/app/api/webhooks/outgoing/route.ts | List/create webhook subscriptions |
src/app/api/webhooks/outgoing/dead-letter/route.ts | Dead-letter queue and replay API |
outgoing_webhook table | Subscription records |
outgoing_webhook_delivery table | Delivery attempts and results |
Dispatching an event
import { dispatchEvent } from '@/lib/outgoing-webhooks';
await dispatchEvent('subscription.created', {
userId,
subscriptionId,
plan: 'pro',
});
Matching rules:
*receives every event.user.*receives every user event.payment.completedreceives only that exact event.
Delivery format
Each delivery sends JSON with an event ID, event name, payload, and timestamp. Requests include:
| Header | Purpose |
|---|---|
X-Webhook-Id | Subscription ID |
X-Webhook-Signature | HMAC-SHA256 signature |
X-Webhook-Event | Event type |
Retries and dead letters
Failed deliveries are retried with exponential backoff up to the configured maximum attempts. Deliveries that still fail are marked as dead-lettered and can be replayed from the admin endpoint.
Feature flag
ENABLE_WEBHOOKS="false"
When disabled, webhook dashboard and API surfaces return 404.