Retries and duplicates
Answer fast, take each event once, and know when YOU(th) tries again.
YOU(th) delivers every event at least once. A delivery your receiver does not take comes again, and one it took can come again too, after a network error. Build your receiver for both.
Answer fast
A delivery counts as taken when your receiver answers any 2xx within ten seconds.
- Verify the signature.
- If you have seen its
event_idbefore, answer200and stop. - Store the event, answer
200, and do the work afterwards, outside the request.
Answering fast matters more than finishing the work: a receiver that reads the checkup before it answers can run past ten seconds, and then the same event comes again.
When YOU(th) tries again
| Answer | Retried |
|---|---|
A timeout, a network error, 429 or any 5xx | Yes |
Any other 4xx, or any 3xx | No |
Answer 4xx only when a delivery can never be taken, such as one whose signature fails.
YOU(th) makes up to eight attempts, numbered in the youth-delivery-attempt header. The waits
between them double from about one minute: about 1, 2, 4, 8, 16, 32 and 64 minutes, each varied by
up to 20%, about two hours in all. After the eighth attempt, YOU(th) stops trying that event. The
API lists what you missed: access codes and
checkups.
When an address is gone
An endpoint that answers 404 or 410 to ten different events in a row is paused: YOU(th) stops
sending to it, and its status reads paused. Any 2xx in
between resets the count, and a 5xx, a 429 or a timeout never pauses an endpoint: a receiver
that is down comes back. To receive again,
create an endpoint for an address that answers,
disable the paused one, and read what you missed from the API.
Take each event once
An event's event_id, also in the webhook-id header, stays the same on every attempt. Keep the
ids you have handled, for a few days at least, and skip one you have seen.
While a new event type is sent beside the one it replaces, the same fact also comes under two
event_ids: Versions says how to take it once.
Order
Deliveries can arrive in any order: a retry of an older event can come after a newer one. Read the current state from the API rather than relying on the order events came in.
Test your receiver
Send your receiver the signed request on Verify a delivery: it must
accept it with the fixture secret and your clock set to its webhook-timestamp, and refuse it when
one byte changes. For real deliveries, signed with your own secret, use your
sandbox: a tester who redeems a code there makes an
AccessCode.redeemed.