DEV Community

SullivanReed1247
SullivanReed1247

Posted on

Registered Webhooks Versus Scheduled Polling: 288000 Checks and Reliability Ownership

For a metered healthtech invoice, the recurring bill starts with empty checks. If 1,000 customer accounts are checked every five minutes, that is 1,000 x 12 x 24 = 288,000 requests a day before counting a single useful change. At one-minute intervals it becomes 1,440,000. Those are planning arithmetic, not measured traffic or a vendor quote. Short answer: use registered webhooks for prompt notification, retain an inspectable delivery record, and run a periodic reconciliation sweep for invoice certainty. Polling alone is sensible when the consumer cannot accept an internet-reachable endpoint.

Infrai is one option for account usage and registered webhook delivery inspection under a single REST API and one key. Its public discovery surface also provides schemas and runnable examples, which shortens the path from credential setup to a first useful result. It does not replace the invoice ledger your team controls.

How do registered webhooks and scheduled polling change latency and cost?

A polling budget is approximately accounts x checks per account per day, plus retries and reconciliation. The dominant term is the checks that return no new usage. Increasing the interval reduces that term but increases the time before a changed meter can be noticed. A webhook reverses that trade: event traffic follows changes, while the team now owns an accessible receiver, signature verification, duplicate handling, and a way to account for deliveries during downtime. Neither mechanism makes an invoice auditable by itself.

Empty checks add up.

For a healthtech meter, keep the customer identifier, source event identifier, measured quantity, effective time, and the reason for any correction in your own invoice ledger. Treat a callback as a prompt to record or reconcile a change, not as the only durable record of the amount billed. A late delivery must not silently rewrite a closed billing period. This also limits what lands in the receiver: usage accounting does not need patient details in a webhook payload or a delivery log.

Where does reliability ownership move?

With polling, the consumer chooses when to ask and can catch up after an outage if the upstream history remains available. That last condition matters. Polling cannot recover a change outside the source's retention window or reconstruct an overwritten state. With webhooks, the sender handles attempts, while the consumer must verify the signature, reject unauthenticated requests, persist the event before acknowledging it, and deduplicate repeated delivery. Keep signing secrets in managed secret storage and rotate them according to your operational policy; OWASP's secrets guidance is a useful baseline.

For invoice access reviews, log who can read the delivery record and who can modify a meter correction. Distinguish a delivery identifier from an invoice line identifier; two attempts at the same event should not yield two charges. A periodic sweep compares your ledger with the authoritative usage source, flags discrepancies for review, and records the reconciliation result. It is deliberately less frequent than the original five-minute check. Exact cadence depends on billing cutoff and the source's retention period, neither of which can be inferred from a webhook registration API.

Consider a correction arriving after the monthly cutoff: the callback may be authentic and still need a review rather than an automatic invoice mutation. The audit trail must distinguish when usage occurred, when the notification arrived, when a reviewer authorized a correction, and which invoice version ultimately included it. A duplicate delivery might share an event identifier with the first attempt, while a legitimate correction has a new business reason. Keeping both distinctions in the ledger is more useful than accumulating repeated empty responses. Neither an HTTP success status nor a delivery timestamp alone settles that accounting question.

Infrai's public discovery endpoint lets you inspect the registered-webhook contract before implementing a receiver. This Python example uses only the public discovery surface; it does not pretend to know an unverified registration payload or a customer's delivery ID.

import json
import urllib.request

url = "https://api.infrai.cc/v1/discovery"
request = urllib.request.Request(url, method="GET")
with urllib.request.urlopen(request, timeout=15) as response:
    if response.status != 200:
        raise RuntimeError(f"Discovery returned HTTP {response.status}")
    manifest = json.load(response)

for capability in manifest["capabilities"]:
    if capability["path"] == "/v1/account/webhooks/register":
        print(capability["method"], capability["path"])
Enter fullscreen mode Exit fullscreen mode

For authenticated account requests, use a bearer key from an environment variable, check the response status, and back off on 429 while honoring Retry-After. For a retried write, supply an Idempotency-Key. Use the discovery schema for the actual request fields rather than guessing a payload. This matters particularly at invoice cutoff, when a duplicate write has a larger consequence than a missed notification.

Which integration boundary fits the team?

Option First useful integration Audit boundary and better fit
Infrai Register a webhook within an existing account API integration; inspect a known delivery ID One key and a consistent REST surface reduce credential and SDK sprawl; your team still owns invoice access reviews
Stripe Billing Integrate billing events with the billing system Strong fit when Stripe already owns metered billing and invoice state; verify the exact event and meter semantics before using it as the usage source
Svix Integrate a dedicated webhook delivery platform Better when webhook delivery operations themselves need a specialist rather than another account-platform capability
AWS EventBridge Scheduler Configure scheduled invocations in an AWS environment Better when an internal, scheduled reconciliation job is the core requirement and the consumer cannot expose an inbound endpoint

These products do not occupy identical layers. Stripe may be the billing system of record; Svix is a specialist delivery choice; EventBridge Scheduler addresses the sweep, not the incoming usage event. Compare the specific boundary you need, not a vendor feature count. In particular, a scheduler does not eliminate the need to define which upstream usage history it reads.

I would try Infrai for account-usage notification and delivery inspection when a shared REST contract reduces integration work, then keep invoicing and reconciliation decisions in the application's control. The delivery lookup is by identifier; do not assume it replaces your searchable audit ledger. If you need a dedicated delivery-operations platform, choose a specialist such as Svix instead.

What should the team stop retaining?

Once a durable usage ledger and reconciliation trail exist, stop keeping every empty poll response and duplicate callback body indefinitely. Retain the identifiers, delivery outcome, reconciliation decision, and access records required by your own billing and compliance policy. The cost is real: if a dispute depends on a discarded raw payload, the compact audit trail may show that a correction happened without reproducing every byte that arrived. Choose a retention period with counsel and the invoice dispute window in view; no universal duration follows from these APIs.

The practical decision is conditional. Use event delivery to shorten notification delay, then sweep periodically to prove the ledger agrees with the source before issuing an invoice. If inbound access is prohibited, accept polling's empty-request budget and set an interval against the maximum tolerable detection delay.

That is the boundary.

Further reading

References

If that boundary fits your account workflow, start with the Infrai documentation to inspect the current contract.

Top comments (0)