Webhook vs API is a choice about who starts a request, not which technology replaces the other. An API is an interface you call; a webhook sends an event-triggered request to an endpoint you expose. Use API calls for commands and state reads, webhooks for notices, and both when those notices need state checks or recovery.

Webhook vs API: the short answer

A webhook calls an API endpoint. The event source starts that call when something happens; your service receives it. With a plain API read, your service starts the call to ask the source for data.

Polling repeats those reads on a schedule. An API call need not be polling.

You might fetch one object on demand or send a command once. Do not assume that push always beats pull.

GitHub’s webhook overview describes event subscriptions and HTTP requests sent to a chosen URL. It also says direct API calls can fit when you need data once or only now and then. Start with your actual need for fresh data and the events the source supports.

Question API call or polling Event webhook
Who starts the request? Your service The event source
What triggers it? A user action, job, or schedule A subscribed event
Which endpoint receives it? The source’s API endpoint Your chosen receiver
What do you get? The response defined by that API The event payload defined by that source
What can fail? A read, command, response, or next polling job Delivery, acceptance, or later work
Common role Commands and state reads Notifications that start work

For a webhook URL example, use https://hooks.example.invalid/events as a fictional receiver address. The source must be able to reach the real route you configure.

The URL does not prove who sent the request. Use the source’s checks, not the address alone.

Webhook vs REST API is not a clean protocol split either. GitHub’s webhook delivery is an HTTP request, while its REST API supports caller-started requests. The difference here is the trigger and direction of the call.

How push notices and API calls work together

Consider a payment-state system. This is a design example, not a real payment incident or tested system.

Your backend needs to learn when the source confirms a payment. It must update its records without making the same business change twice.

Stripe’s webhook guide uses payment updates as an example of events that happen later. It also says API calls can retrieve missing objects.

These two paths can serve the same system. Neither path gives a promise that holds in all cases.

  1. Your backend creates or reads a payment through the source’s API. It records the source object ID and its local task.
  2. The source later sends a subscribed event to your receiver. The receiver verifies the request and checks that the event is one it handles.
  3. Your service saves the work so it survives a crash, then replies within the source’s deadline. A worker performs the slower business step.
  4. If an event lacks the state you need, the worker reads the needed object through the API. A recovery job also checks open local tasks within a stated window.

The durable-save rule is our design advice. Check it against your queue, storage, and delivery contract.

If you reply before saved work can survive a crash, the sender may mark the request complete. Your service could still lose the task.

Doing all business work before the response can miss a sender’s deadline. A fast HTTP 2xx should mean the agreed save step worked. It is not proof that the worker, database update, email, or later service has finished.

Keep those states apart in logs: received, verified, accepted, processed, and reconciled. Give each failure a place to surface. Otherwise a successful delivery chart can hide a failed job behind it.

Suppose the receiver saves a task and sends 2xx. The worker then stops before it changes the local state. The sender saw a reply; your team still has work to do.

Keep that task in a place the next worker can find. A retry must check what the first worker did before it acts again. This is why the job needs its own state and owner.

In this webhook vs API example, the event is a prompt to work and the read is a way to obtain needed state. A state read may not show every past change. If your task needs a full history, verify the source’s event archive and replay rules too.

Illustrated API read and return above event delivery, receiver verification and saved work sent to a worker

Original illustration: reads and events start at opposite ends

When to use API calls, webhooks, or both

Use this decision path before choosing a queue or framework. It is a guide to tradeoffs, not a rule that fits every service.

Read the source’s rules. Check that the event or recovery endpoint you need exists.

  1. Need data once or only now and then? Start with an on-demand API read. Do not add a public receiver just to avoid a small number of reads.
  2. Need prompt notice of a supported event? Check whether you can run a reachable receiver and verify requests. If yes, consider webhooks; if not, evaluate polling within the source’s limits.
  3. Need current state as well as notice? Use the event to trigger a scoped API read when the payload lacks that state. Avoid fetching unrelated objects on every event.
  4. Need a way to close missed-state gaps? Add a bounded recovery path using supported state reads or event replay. Name the window, owner, and limits before relying on it.

Polling offers a schedule you control, but you must run the jobs and budget their requests. Its interval also affects how soon a change can be noticed. Webhooks move the event trigger to the sender, while adding an inbound route and the need to handle its delivery behavior.

Neither choice sets one fixed cost or speed. Compare the workload, events, read limits, storage, and recovery work for your case. A hybrid design adds two paths to maintain, so justify both with a specific need.

The webhook vs WebSocket question concerns a different boundary. RFC 6455 defines two-way communication over a connection; a webhook is the event-triggered HTTP delivery described above. Sending a webhook to your backend does not itself open a browser connection.

If the browser needs updates, design that later hop separately. Do not expose the browser as the public webhook receiver or assume an inbound payment event directly refreshes its UI. The central choice here remains how your backend learns and checks source state.

Illustrated choice path from prompt notice and receiver support to API reads, polling or webhooks with scoped reads

Original illustration: add reads when state checks or recovery call for them.

The delivery contract to check before code

These facts come from docs checked October 6, 2026. That is a retrieval date, not a release or incident date. GitHub and Stripe have different contracts; their numbers and headers are not rules for all webhook sources.

Verify and accept

GitHub’s best practices recommend HTTPS with certificate checks, a webhook secret, and only the events you need. Check the event type and action before acting. An unexpected event should not enter a business path merely because it arrived at the right URL.

Stripe needs the raw request body for its signature check. A framework changing those bytes can make the check fail.

Use the supported signature check before trusting event fields. JSON parsing is not that check.

Choose and test the actual framework and SDK before writing code. Check how the route keeps raw bytes and uses the correct endpoint secret. There is no untested code sample or pinned API version here.

GitHub says to respond with a 2xx within 10 seconds and suggests a queue for background work. Stripe asks for a quick 2xx before complex logic.

Measure your verified save path against the actual source deadline. Do not copy ten seconds into every system.

Handle duplicates and order

Stripe says an endpoint can receive the same event more than once. It also does not promise delivery in the order events were created. Build the state rules so that an older notice or repeat attempt cannot blindly repeat a business action.

GitHub’s X-GitHub-Delivery header stays the same on a requested redelivery. Stripe documents tracking event IDs for repeats, and notes that separate event objects can sometimes describe duplicate activity. Read the source’s exact identity rules before choosing your stored key.

A delivery ID and a business task are not always the same identity. Do not suppress all later updates to an object just because its ID appeared before. See the idempotency and retry guide for the deeper intended-effect and recovery boundaries.

An event-ID store needs a lookup path that fits the query. The database indexing guide explains how to assess that query cost. An index alone does not prove uniqueness, atomic acceptance, or a safe result when two workers race.

Recover missing state

Stripe documents automatic retries for up to three days in live mode, with backoff. Its sandbox behavior differs, and a disabled or deleted destination can stop later attempts. Do not treat that window as proof that every notice eventually arrives.

GitHub recommends redelivering missed deliveries after your receiver returns. Those are sender actions.

Your workers still need their own failure path. A redelivery does not prove that a later business step worked.

To reconcile state, start with open local tasks and the source IDs they already hold. Read only the state or history needed for those tasks.

Check query filters, pagination, rate limits, and the archive window. Use those rules to choose a schedule.

Define where the job resumes after a crash and what happens when a gap is older than the recovery window. A queue of open items needs an owner, not just another retry timer. A read can repair your state view only if the source shows the state you need.

Illustrated timeline from a missed notice to an open-task API read and local state reconciliation

Original illustration: query available state within the source’s limits; history may be incomplete.

A compact system checklist

Before launch, keep one short contract record beside the receiver and recovery job. Name the events, payload/API version, signature flow, deadline, event identity, and order rules. Add retry/replay windows, API read limits, and who owns failed work.

Check how the queue saves work, how much it can hold, and the age of waiting work. Agree what the receiver does when it cannot accept a task. Do not send a success just to make a dashboard look healthy.

Failure to exercise Boundary to check What to inspect next
Changed or untrusted request Signature check before use Raw bytes, endpoint secret, rejection path
Receiver stops before saving work Meaning of the reply Whether accepted work survived
Same event arrives again Intended business effect Stored identity and downstream action
Older event arrives later State transition rules Current state and allowed change
No notice is received Recovery scope Supported reads, pagination, and remaining window
Worker fails after receipt Who owns the job Failed jobs and the path to resume

Use test events and failure cases in your chosen setup. Observe receipt and job completion apart.

Neither replaces the other. These are checks to run. They are not claims that Amazi has tested your source or achieved exactly-once delivery.

The useful output is a clear contract and a workflow you can repair. API calls supply commands or reads; webhooks supply event-driven deliveries.

Combine them where the task needs both, and leave each failure visible.