Skip to main content
A webhook task is a task with an endpoint attached: webhook() starts a task run for each delivery that passes its filter. If an attempt fails, the run retries and calls onEvent again, so keep its side effects safe to repeat.

Handler arguments

onEvent receives:

Task options

webhook() also takes the options a task does, such as queue, concurrency, machine, retry, maxDuration and the lifecycle hooks. For example, to handle one delivery at a time:
/trigger/stripe-orders.ts

Group deliveries per customer

The limit covers every delivery the task handles. To group each customer’s events while different customers run in parallel, route them to an agent with session routing: deliveries with the same key land in one session and are handled one at a time. A retried delivery can reach the session after a later one, so don’t rely on arrival order.

Endpoint options

webhooks.endpoint.define also takes a description and metadata. The metadata is passed to every subscriber as endpoint.metadata. The endpoint id can’t start with wh_, which is reserved for the ids Trigger.dev generates.