Skip to content

Delivery settings

Webhook delivery settings control how Layeron accepts inbound events and delivers outbound events.

Inbound webhooks queue accepted events and run handlers asynchronously:

Terminal window
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:

SettingDefault
queuetrue
deadLettertrue
retry.attempts5
retry.backoffexponential
retry.initialDelaySeconds5
retry.maxDelaySeconds300

Each outbound endpoint can set its own retry policy:

Terminal window
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.

Set a dedupe TTL to match the provider’s retry window:

Terminal window
dedupe: {
key: "body.id",
ttl: "7d",
}

Supported TTL units:

UnitExample
Seconds30s
Minutes15m
Hours12h
Days7d

Enable product observability when you want webhook metrics and operational signals included with the rest of your app:

Terminal window
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:

Terminal window
handler: async (event, ctx) => {
await ctx.log("Webhook accepted", {
eventId: event.id,
eventType: event.eventType,
})
}