In this guide 6 sections
An API call is your system asking another system a question and waiting for the reply, so you choose the timing and the answer comes back immediately. A webhook works the other way round: the other system calls a web address you registered the moment something happens on its side. Most real integrations need both.
Two ways to get data: asking and being told
You start every API call. Your order system asks the courier’s server whether a parcel has shipped, and the courier replies at once with whatever status it holds right now. Nothing moves until you ask.
A webhook reverses the direction. Instead of asking again and again, you register a web address with the courier, and the courier calls it when a parcel is collected, delayed or delivered. You hear about it without asking.
Webhooks are sometimes called callbacks, and the idea never changes: the sender pushes, and the receiver listens at an address it published and acts when a message lands. A paid invoice is a typical trigger. A shipped order is another.
Polling, latency, reliability and control
Asking repeatedly is called polling. Poll the courier every ten minutes and you learn about a delivery up to ten minutes late, while polling faster multiplies requests that providers cap or bill. Control comes at a price.
A webhook delivers news almost instantly with little wasted traffic, but your server must be reachable and ready to accept the message whenever it arrives. Downtime is the risk. Reliable senders retry with exponential backoff, doubling the wait after each failure until a retry window closes, and a sender without one may drop your event after one attempt.
Choose the polling interval by asking what a late answer costs: a stock count ten minutes old is harmless, while a payment status that old can stall a customer. Long lists need pagination, one request per page of results, so a single full sweep of open orders can cost dozens of calls against the provider’s quota.
Both patterns in one everyday business flow
Consider an online electronics store: when an order is created, it calls the courier’s API to book a pickup and receive a tracking number. The store starts that request. It needs an answer now.
After booking, the store stops asking. It registers a webhook instead, so the courier’s system notifies the store when the parcel is out for delivery, delivered or a delivery attempt fails. One flow, two patterns.
Authentication, retries and duplicate handling on either side
Security runs in opposite directions. An outgoing call proves who you are with a key or token, while an incoming webhook must prove the sender really is the courier, usually through an HMAC signature. Check the signature before acting.
Duplicates are the second hazard. A retried API call may run twice if its first reply was lost, and a webhook sender may deliver one event twice on purpose, to be safe. Record each order ID or event ID when you first act on it, and skip any message carrying an identifier you have already processed.
Webhooks can arrive out of order, so a delivered message may land before the earlier out-for-delivery one and leave a parcel showing the wrong status. Keep the sender’s event number. Discard stale updates. Send a quick acknowledgment first and do the heavy work afterwards, since a slow reply makes the sender assume failure and resend.
Choosing the right pattern for each event
Use an API call when you need an answer right now or when you are starting an action, such as booking a pickup or charging a card. Use a webhook when the other system acts on its own schedule, such as a depot scan, and being told quickly matters more than choosing when to ask.
Mature integrations use both. API calls cover the actions you start, webhooks cover the events you must react to, and a periodic check catches anything a webhook missed. Choosing only one pattern for every case means either paying for pointless polling or losing the ability to trigger actions on your own schedule.
List every event your business reacts to, and beside each write whether you start it or the other system does, because that answer picks the pattern.
Polling-versus-webhook sequence
Two diagrams, one parcel. The left diagram shows the store polling the courier’s API at intervals, while the right shows one webhook registration followed by a push the moment the status changes. The delay is marked on each.
Open a blank worksheet to printQuestions owners ask
Can webhooks replace every API call?
No. Webhooks only report events the other system chooses to announce, so they cannot answer a question on demand or start an action such as booking a shipment. Most integrations need both patterns working together.
What if a webhook is missed?
Add a periodic backstop. For example, list every order still marked in transit after two days and ask the courier for its status, so a lost message never leaves a record stale.
Who should own webhook endpoints?
Name one person or team to watch failed deliveries, renew signing secrets, read the provider’s change notices and answer the first alert when an endpoint stops receiving messages. Silence is the warning sign. Where the sender offers a heartbeat event every few minutes, raise an alert the moment it stops arriving, because a quiet endpoint and a healthy one look the same.
