Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Courses/Asynchronous and Event-Driven Systems
Lesson 12 of 20

Webhooks

Deliver events to servers you do not control: retries, isolation, signing and safety.

15 min read

Your consumer is someone else's server

A webhook is an HTTP POST you send to a customer's URL when something happens. Unlike your own consumers, that endpoint may be slow, return errors for hours during their deploy, be misconfigured forever, or point at something it should not. Delivery must never happen inside the request that created the event, and one customer's broken endpoint must never affect anyone else.

The delivery pipeline

When an event occurs, record it durably and enqueue one delivery per subscribed endpoint. Delivery workers POST with a short timeout (5 to 10 seconds) and treat any 2xx as success. Everything else is retried with exponential backoff and jitter over a long window; Stripe, for example, retries for up to three days. After the window, mark the delivery failed, disable endpoints that keep failing, notify the customer, and let them replay missed events from a dashboard or API.

Isolate customers

If all deliveries share one queue and one customer's endpoint starts hanging for 10 seconds per request, workers pile up on it and everyone's webhooks slow down. Isolate by customer: per-endpoint concurrency limits, separate queues or partitions for large tenants, fair scheduling across tenants, and a circuit breaker per endpoint that pauses delivery while it is down and resumes from the backlog when it recovers.

Security and the contract

Receivers need to trust and handle what you send.

  • Sign each payload with HMAC-SHA256 using a per-endpoint secret, and include a timestamp so receivers can reject replays older than about 5 minutes
  • Include a unique event ID so receivers can deduplicate; document that delivery is at-least-once and unordered
  • Block private and link-local IP ranges at send time to prevent server-side request forgery
  • Consider thin payloads (event type and object ID) so receivers fetch current state instead of acting on stale data
  • As a receiver, verify the signature, return 2xx quickly and process the event from your own queue

Key takeaways

  • Treat webhook endpoints as unreliable and untrusted; deliver from a queue, never inline
  • Retry with backoff over hours or days, then disable and let customers replay
  • Isolate customers so one slow endpoint cannot delay the rest
  • Sign payloads, include event IDs and timestamps, and guard against SSRF

Sign in to track lessons and earn badges.

Scheduling and delayed jobsReal-time push: WebSockets, SSE and long polling

Challenge checkpoint

Course: 0/20 lessons · 0/10 challenges0%

Build it on the canvas, pass the review (70+) and mark it complete to count it toward the course badge.

  1. 6/10Design Webhook DeliveryDeliver signed events to customer endpoints with long retries, a DLQ and per-customer isolation.Medium
All 10 challenges →