🪝 Webhooks

How to process webhook payloads to ensure timely responses.

In order to respond in a timely manner, we suggest setting up a queue to process webhook payloads asynchronously. Your server can respond when it receives the webhook, and then process the payload in the background without blocking future webhook deliveries. Background processing of webhooks is preferred over inline processing.

Background Processing vs Inline Processing

Inline processing involves executing tasks immediately within the current execution context, potentially leading to longer response times. Background processing involves deferring tasks asynchronously, placing them in a queue for later execution. This allows the application to quickly respond to initial requests without waiting for the task to complete.

How should I handle webhook requests?

When receiving a request, it's essential to be attentive regarding three key issues:

  1. Quickly respond to webhook requests
  • If an incoming webhook triggers lengthy processing in your system, we recommend you create a processing queue for events. If you don't implement a process, a timeout may result, and you will receive a webhook retry.
  1. Place importance on responsiveness over availability
  • As the handler of incoming webhooks, ensuring continuous availability is paramount. Fortunately, the response to a webhook doesn't need to include the processing results in it. Your setup can acknowledge the webhook request initially and process it later, facilitated by introducing queues between receipt and processing.
  1. Deduplicate incoming events
  • We can't guarantee that webhook messages will be delivered only once, so it's essential to include a mechanism that prevents duplicated events.

Webhook Security Best Practices