Delivery settings
Webhook delivery settings control how Layeron accepts inbound events and delivers outbound events.
Inbound delivery
Section titled “Inbound delivery”Inbound webhooks queue accepted events and run handlers asynchronously:
const vendor = webhooks.custom({ name: "vendor", path: "/webhooks/vendor", delivery: { queue: true, deadLetter: true, retry: { attempts: 5, backoff: "exponential", initialDelaySeconds: 5, maxDelaySeconds: 300, }, }, handler: async (event) => { await processVendorEvent(event.payload) },})Defaults:
| Setting | Default |
|---|---|
queue | true |
deadLetter | true |
retry.attempts | 5 |
retry.backoff | exponential |
retry.initialDelaySeconds | 5 |
retry.maxDelaySeconds | 300 |
Outbound retry policy
Section titled “Outbound retry policy”Each outbound endpoint can set its own retry policy:
const events = webhooks.out({ name: "account-events", endpoints: [ { name: "partner", url: "https://partner.example.com/webhooks/account", retry: { attempts: 10, backoff: "exponential", initialDelaySeconds: 15, maxDelaySeconds: 900, }, }, ],})Use higher retry counts for systems that have maintenance windows or temporary rate limits.
Dedupe windows
Section titled “Dedupe windows”Set a dedupe TTL to match the provider’s retry window:
dedupe: { key: "body.id", ttl: "7d",}Supported TTL units:
| Unit | Example |
|---|---|
| Seconds | 30s |
| Minutes | 15m |
| Hours | 12h |
| Days | 7d |
Observability
Section titled “Observability”Enable product observability when you want webhook metrics and operational signals included with the rest of your app:
const vendor = webhooks.custom({ name: "vendor", path: "/webhooks/vendor", observability: { logs: true, errors: true, metrics: true, }, handler: async (event) => { await processVendorEvent(event.payload) },})Use ctx.log(...) inside handlers for event-specific support details:
handler: async (event, ctx) => { await ctx.log("Webhook accepted", { eventId: event.id, eventType: event.eventType, })}