API Engineering

Webhooks vs APIs: Polling vs Event-Driven Push Notifications Explained

Webhooks vs APIs: Compare polling with reverse APIs. Learn when to use webhooks for real-time payment confirmations, GitHub commits, and order updates.

By Cometflow API Engineering Team • Updated 2026-10-06

While standard HTTP API requests rely on client polling ("Is the payment done yet?"), webhooks invert the control flow. A webhook is a user-defined HTTP callback where the provider pushes an HTTP POST payload to your server URL the moment an event occurs.

1. Polling vs. Webhook Architecture

POLLING (Client-Initiated):
Client ──[GET /v1/jobs/123]──> Server ("status: processing")
Client ──[GET /v1/jobs/123]──> Server ("status: processing")
Client ──[GET /v1/jobs/123]──> Server ("status: completed")

WEBHOOK (Server-Initiated Event Push):
Provider ──[POST https://api.yoursite.com/webhooks/payments]──> Your Server
Body: { "id": "evt_99", "type": "invoice.paid", "data": { "orderId": "123" } }
Your Server ──[200 OK]──> Provider (Acknowledge receipt within 5 seconds)

2. Engineering Best Practices for Webhook Receivers

  • Acknowledge Fast, Process Async: Return 200 OK immediately after verifying the signature and pushing the event to an internal queue; never run slow PDF generation or 3rd-party calls synchronously inside the webhook handler.
  • Handle Duplicate Delivery: Webhook providers use at-least-once delivery. Store processed event.id values in a unique database column so retries do not trigger duplicate emails or double fulfillment.

Frequently Asked Questions (FAQ)

What happens if my server is down when a webhook is sent?

Enterprise providers (like Stripe, GitHub, and Shopify) retry failed deliveries (non-2xx responses or timeouts) on an exponential backoff schedule for up to 24 to 72 hours.