A billing system that uses webhooks to deliver event notifications has two distinct failure surfaces. The first is on the sender side: did the event get written to the ledger before the webhook fired? The second is on the receiver side: did the webhook consumer process the event and acknowledge it, or did it silently fail? Most billing webhook implementations handle the first surface and assume the second. For low-volume billing, the assumption is often harmless. For high-volume AI agent billing, the accumulated cost of silent receiver failures is real revenue that was never recognized.

The Delivery Problem

HTTP webhook delivery is inherently unreliable. The sender fires a POST and expects a 200 response. If the receiver's endpoint is temporarily unavailable, returns a 5xx error, or times out, the delivery has failed. What happens next depends entirely on the sender's retry logic. If there is no retry, the event is lost. If there is retry without idempotency, the event may be delivered multiple times, creating duplicates. The correct pattern is retry with idempotency, where the sender retries until it receives a 200 and the receiver deduplicates on the event ID.

At high event volumes, even a low delivery failure rate accumulates. A webhook endpoint that returns errors 0.5 percent of the time during peak load and retries successfully on the second attempt produces accurate results. A webhook endpoint with a 0.5 percent permanent failure rate (events that exhaust retries without delivery) produces a billing gap of that percentage across the total event volume. At 2 million events per month, that is 10,000 events that were never recorded.

Acknowledgment Is Not Confirmation of Processing

A 200 response from a webhook endpoint confirms that the HTTP delivery succeeded. It does not confirm that the receiving application processed the event correctly. If the receiver returns 200 before writing to its database, and the write subsequently fails, the sender considers the delivery complete. The event is not in the receiver's database. From the billing ledger's perspective, the event was delivered. From the application's perspective, it was not processed.

The correct pattern for webhook receivers in billing-critical systems is to acknowledge only after successful persistence: write the event to durable storage, confirm the write succeeded, then return 200. This pattern means that any failure in persistence will cause the webhook sender to retry, rather than treating the delivery as complete. The tradeoff is slightly higher latency to acknowledgment, which is acceptable when the alternative is silent data loss.

Billing Event vs. Billing Notification

There is an important distinction worth making explicit. The event that records usage in the billing ledger should be persisted independently of any webhook notification about that event. If your billing architecture requires a webhook to be successfully delivered before the usage is written to the ledger, you have made your billing integrity dependent on webhook reliability. These should be separate concerns.

The billing event is written to the ledger on ingest, synchronously with the API call that submitted it. Webhook notifications about billing events (invoice generated, threshold crossed, payment due) are asynchronous notifications derived from the ledger state. A failed webhook notification about an invoice does not affect the invoice's existence. The customer can be notified again. A failed write to the billing ledger is a data integrity problem with no easy remedy.

Monitoring What You Cannot See Without Instrumentation

Silent webhook failures are invisible without explicit monitoring. The sender marks the delivery attempt as failed after exhausting retries, but that signal often lives in an error log that no one reads in real time. The billing ledger has no gap that is obviously visible, because the failed events were never written to it. The discrepancy only surfaces when a customer reconciles their own usage logs against their invoice and finds the numbers do not match.

Practical monitoring for webhook reliability in billing systems includes: delivery attempt rate and success rate per endpoint, retry depth distribution (what fraction of successful deliveries required one retry, two retries, or more), and a daily reconciliation check that compares the count of events submitted to the ingest API against the count of events in the billing ledger for the same period. Any gap in the reconciliation is a signal to investigate delivery failures before they become billing disputes.

Short posts on billing infrastructure

Practical notes on event metering, webhook reliability, and usage-based billing for AI products. Monthly, no filler.