Communication / 6 / 6
Sending webhooks reliably
A payment service tells online shops that a payment went through by calling their URL: a webhook. How to send it without blocking payments, how the shop knows the call is real and fresh, and how both sides survive retries, duplicates, out-of-order events and endpoints that are gone.
- 14 min
- Intermediate
- 12 steps
- Payment p95
- 8 200 ms
- Fake events accepted
- 0
- Double fulfilments
- 0 /day
- Pending deliveries
- 0
- request
- reply
- redelivery
- duplicate
- lost
- call: the reply returns on the same line
Numbers are a model scenario, not measurements
The real request
Payments API → Shop serverRequest
POST /hooks/payments HTTP/1.1
Host: shop.example.com
Content-Type: application/json
{
"type": 1"payment.succeeded",
"data": { "payment_id": "pay_771", "order_id": 2"ord_5521", "amount": 129000 }
}
Response
HTTP/1.1 200 OK
X-Response-Time3: 8100 ms
type— What happened. The shop decides what to do by this name.order_id— The shop's own order, so it knows what to ship.X-Response-Time— 8.1 s of the payment spent waiting for the shop.
Build it yourselfCheat sheetCompare lessons
Course: 74 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes
11 Case studies