Skip to main content

Webhook best practices

The following guide describes some best practices for working with webhooks.

Respond quickly

After receiving a webhook using an HTTPS endpoint, it's important to respond to the request with a 2xx (200) HTTP status code as quickly as possible.

A common pattern is to store the payload in a message queue for later processing by a background worker. This reduces the chance of the request timing out and the webhook delivery counting as a failure.

Ignore duplicates

Although the webhooks API is designed to minimize duplicate webhook events, it is still possible to receive the same event more than once. Your endpoint should handle webhook events using idempotent operations; that is, receiving the same webhook event a second time in a row should have no additional effect. You can detect duplicate webhook events by looking for identical id fields.

Implement reconciliation jobs

Your app shouldn't rely solely on receiving data from webhooks. Because webhook delivery isn't always guaranteed, you should implement reconciliation jobs to periodically fetch data from Mailabl.