What is the difference between webhooks and polling?

Web API & REST API Design Intermediate 2–3 Yrs3–5 Yrs Architecture 1 min read

Quick Answer

Polling — the client repeatedly asks “anything new?”. Simple, but wasteful and delayed. Webhooks — the server calls the client's URL when an event happens. Real-time and efficient, but the client must run an endpoint, verify the payload signature, handle retries and be idempotent.

With polling the client keeps asking the API whether anything changed — it's simple but it's either wasteful if you poll often or laggy if you poll rarely. With a webhook, the provider POSTs to a URL you registered when the event actually happens, so it's real-time and efficient. The cost is on the receiver: you have to host an endpoint, verify the signature so you know the call is genuine, respond fast and process asynchronously, and be idempotent because the sender will retry and you'll get duplicate deliveries. For very frequent updates I'd use SignalR or WebSockets instead.

  • Poll when: you can't expose an endpoint, events are frequent enough that you'd poll anyway, or simplicity wins.
  • Webhook when: events are sparse and latency matters (payment succeeded, build finished).
  • Webhook must-haves: signature verification (HMAC of the body with a shared secret), idempotency (the sender retries, so process each event id once), quick 2xx response then process async, and a way to replay missed events.
  • WebSockets / SignalR / SSE are the persistent-connection alternatives for high-frequency updates.