FresherTechnicalAPI design
What is a webhook and how does it differ from polling?
Try answering first
Model answer
A webhook is an HTTP callback: when something happens, the provider sends a POST to a URL you registered. With polling, you repeatedly ask the provider "anything new?" on a timer.
Polling
- Simple, and works from behind firewalls because you only make outgoing calls.
- Wasteful: most requests return nothing, and updates arrive only as fast as your interval.
- Many clients polling often can overload the provider.
Webhooks
- Near real-time and efficient, because traffic happens only when there is an event.
- You need a public HTTPS endpoint, you must verify the signature, and you must handle duplicates and retries, since delivery is usually at-least-once.
- If your server is down, you can miss events.
A reliable integration combines both: use webhooks for speed, and keep a polling or reconciliation job (or an events API) as a safety net for gaps.
payment succeeds -> provider POST https://you.example.com/webhooks
you reply 200 quickly, then process the event
Pick webhooks for event-driven flows, and polling when you cannot expose an endpoint or events are rare.
Key points
- A webhook is the provider calling your URL when an event happens
- Polling asks repeatedly and wastes requests and time
- Webhooks need signature checks, dedupe and a public endpoint
- Combine webhooks with reconciliation polling for reliability
Likely follow-ups
- How do you verify that a webhook really came from the provider?
- What happens if your endpoint returns an error?
Common mistakes
- Doing slow processing before replying to the webhook
- Relying on webhooks alone with no way to catch up on missed events