Are webhooks retried when they cannot be delivered? Retries, duplicates and ordering

Edited

Yes. When Apideck can't deliver a webhook event to your delivery URL, it retries the delivery automatically. This article explains when a delivery counts as failed, the retry schedule, what happens when all retries fail, and how to handle duplicates and ordering on your side.

When a delivery counts as failed

A delivery succeeds only when your endpoint responds with a 2xx status code within 60 seconds. A delivery fails, and is retried, if your endpoint:

  • returns a non-2xx status code (for example 400, 404 or 500),

  • takes longer than 60 seconds to respond, or

  • can't be reached (DNS or connection errors).

Tip: respond with 200 as soon as you've received the event, and do the actual processing afterwards (for example from a queue). Slow processing inside the request is the most common cause of timeouts and unnecessary retries.

Retry schedule

Apideck tries to deliver each event up to 10 times: the first attempt plus 9 retries. The waits between attempts are:

Retry

Wait after the previous attempt

1st

3 minutes

2nd

5 minutes

3rd

10 minutes

4th

30 minutes

5th

1 hour

6th

2 hours

7th

4 hours

8th

8 hours

9th

12 hours

Together that covers about 28 hours from the first attempt to the last. You can follow each attempt in the webhook logs in your Apideck dashboard.

What happens when all retries fail

If the last attempt also fails, Apideck disables the webhook subscription, and its disabled_reason is set to retry_limit. This applies to every subscription in your application that uses the same delivery URL.

Once your endpoint is working again, re-enable the subscription in the dashboard (Webhooks) or through the Webhook API. Events that already used up all their retries aren't retried again automatically. To catch up on anything you missed, fetch the affected records through the Unified API, for example with filter[updated_since].

Handling duplicate events

You can receive the same event more than once, for example when your endpoint processed it but responded too slowly and the delivery was retried. Make your handler safe to run twice:

  • Deduplicate on the idempotency key header. The x-apideck-idempotency-key header stays the same on every retry of the same event. Store the keys you've processed and skip any you've already seen.

  • Don't deduplicate on the event ID in the body. A new event_id is generated for every delivery attempt, so a retried event arrives with a different one.

Each delivery also includes an x-apideck-event-type header with the event name, and an x-apideck-signature header you can use to verify the event came from Apideck. See Are the Unify webhook events protected by authentication or security signing?.

Ordering

Events aren't guaranteed to arrive in the order they happened. A retried event can arrive hours after newer events for the same record. If order matters, compare the occurred_at timestamp in the payload with what you've already stored, or fetch the latest version of the record from the Unified API before acting on it.

Related

Was this article helpful?

Sorry about that! Care to tell us more?

Thanks for the feedback!

There was an issue submitting your feedback
Please check your connection and try again.