Introduction
Most webhook bugs are not dramatic. A payment provider sends an event while your API is deploying, the request times out, and the provider's retries give up after a day. Or your service commits an order, then crashes before publishing the "order.created" message, so the warehouse never hears about it. Nobody gets an error. The data just quietly disagrees.
These problems sit at the two edges of every event-driven B2B product: events coming in from other systems and events going out to them. Both edges need the same promise. If something happened, the other side will hear about it, even if a process dies at the worst possible moment.
This article covers how to build that promise on Postgres: a webhook ingestion layer that never drops an inbound event, a transactional outbox that never loses an outbound one, and consumers that tolerate the duplicates at least-once delivery created.
Why Fire-and-Forget Events Fail
The naive pattern for outbound events is to write to the database and then call a…