Retries and replay
What happens when your endpoint is down, and how to handle duplicates.
Retries
A delivery succeeds when your endpoint answers with a 2xx within 10 seconds.
Anything else is a failure: a 3xx (redirects aren't followed), 4xx, 5xx, a
timeout or a connection error. Failed deliveries are retried, each attempt after
a longer wait:
| After attempt | Next attempt in |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 30 minutes |
| 4 | 2 hours |
| 5 | 6 hours |
| 6 | 12 hours |
| 7 | 12 hours |
After the 8th attempt, about 32 hours after the first, the delivery is marked failed. It is kept, and you can replay it.
Gladys-Delivery-Attempt says which attempt a request is. An endpoint that keeps
failing is not switched off: each new event still gets its own attempts.
Duplicates
Delivery is at least once. The same event can arrive more than once, for
example when your endpoint did the work but answered too slowly. Every delivery
of an event carries the same event_id, in the body and in the
Gladys-Event-Id header. Record the ones you've handled and skip repeats.
Order
Events can arrive out of order: a retried payment.authorized can land after
the payment.captured that followed it. Don't infer state from arrival order.
Read payment.status in the event, which was the payment's status when the
event happened, or fetch the payment for its current status.
Deliveries log
GET /webhook-deliveries lists your app's 50 most recent deliveries, with what
happened to each:
Prop
Type
Replay
To send a delivery again, for example after fixing a bug in your endpoint:
curl -X POST https://api.joingladys.com/api/v1/webhook-deliveries/{id}/replay \
-H "Authorization: Bearer access_…"It is sent again within seconds, with the same body and event_id, a fresh
signature, and a new set of attempts. You can replay deliveries that succeeded
too. Needs the payments:capture scope.
When you add your first endpoint
Gladys checks for payments that changed without your app being told. When you register your first endpoint, you may receive events for recent payments made before it existed. Handle them like any other event: your duplicate check covers ones you already know about.