Skip to content
atom®technologiesBook a call
Payments correctness

The webhook 2xx boundary: durable inbox write or ledger commit, and who owns each step

For an Adyen-style webhook consumer, we recommend returning 2xx after a durable inbox write and letting an idempotent worker commit to the ledger. That is a labeled design inference to verify against your provider's documented retry behavior.

The short answer

Return 2xx after a durable inbox write and let a separate idempotent worker commit to the ledger. This is our design inference from Adyen's obligations and AWS's retry guidance, not a documented rule. Confirm your provider's retry and timeout behavior, and give the ledger write its own idempotency guard, before adopting either design.

The decision and the failure mode

For a webhook consumer in the style Adyen documents, our recommended default is to return 2xx after a durable inbox write, then let a separate idempotent worker commit to the ledger. Treat that as a recommendation with reasoning, not a settled rule: both Adyen and the Amazon Builders' Library describe their own products, and the comparison between the two designs is ours. Confirm your provider's documented retry and timeout behavior before adopting either design.

The decision is where the acknowledgement boundary sits relative to durable storage and the ledger commit. The failure mode on both sides is duplicate or stalled money movement: the provider retries an event while an attempt of yours is still in flight, or your endpoint stalls and events pile up behind it. Naming the boundary, and naming an owner for it, is a staffing question as much as an engineering one.

What the provider documentation requires

Adyen's documentation defines a webhook as a lightweight mechanism that lets an Adyen service push event-driven messages using HTTP POST calls to an endpoint you define. The integrator's obligations are explicit: accept webhooks with a 2xx HTTP status code, store the message, and process the contents of the message. Adyen calls webhooks an essential feature of a successful integration, partly because many flows are asynchronous, for example iDEAL payments where the final status is not known immediately after the API request. Webhook messages carry a snapshot of the resource so your system can update its own state, and for external events such as chargebacks, Adyen says webhooks are the only way to be notified automatically.

Adyen's documentation states the three obligations together. The ordering between storing, processing and acknowledging is a design decision you must make and write down; treat our reading of it as an inference, and read your own provider's webhook documentation for its retry schedule, timeout and acknowledgement rules before you commit to a boundary. Adyen's documentation describes Adyen's product, not all providers.

Why retries make the boundary matter

The Amazon Builders' Library article on idempotent APIs states the core assumption plainly: retrying a service call as mitigation for a transient fault is based on the simplifying assumption that the operation can be retried without side effects. AWS bakes default retry behavior into some of its SDK implementations, which automatically retry requests that fail from network IO issues, server-side fault, or service rate limiting. The article's example is an EC2 launch workflow where retrying a failed call to create an EBS volume could leave you with two volumes. AWS's stated answer is idempotent API operations, used to mitigate the undesirable side effects of retrying.

The design inference for your endpoint, and it is an inference rather than a documented fact about your system: whatever boundary you pick, some attempt at the money-moving write can overlap another attempt, so the write itself must tolerate repetition. AWS describes its own services and practices, not general behavior, but the retry-with-side-effects problem it documents is the one your consumer has to survive.

Design A: acknowledge after the ledger commits

In this design the endpoint processes the event fully, commits the ledger transaction, and only then returns 2xx. Its appeal is simplicity: one code path, no worker, and the acknowledgement means the money movement is done.

Its cost is coupling. Your acknowledgement latency becomes your ledger latency. Our inference, not a documented mechanism: if the ledger is slow or fails, the provider may time out your response and retry while your first attempt is still running, producing overlapping attempts against the same event. Check that timing risk against your provider's documented timeout and retry behavior before you rely on the design. Under this design the idempotency guard must cover overlapping attempts, not just sequential retries. A proposed mechanism, dependent on your ledger schema and transaction handling: a unique constraint on the provider's event ID inside the ledger transaction, so a second attempt is rejected by the database rather than writing again. Test that mechanism before relying on it.

Design B: acknowledge after a durable inbox write

Here the endpoint writes the raw message to durable storage keyed on the provider's event ID, returns 2xx, and a separate worker processes the inbox and commits to the ledger. This fits the obligations Adyen lists: accept with 2xx, store, process. A design expectation to verify rather than a documented fact: acknowledgement should be fast and should keep working through ledger slowness, because the message is already stored when you acknowledge. Confirm against your provider's behavior that a 2xx response stops its retry loop for that event.

The inbox does not finish the job. This is a proposed architecture inference from the Adyen and AWS guidance, not a finding about your system: a durable inbox separates acknowledgement from processing, and it does not by itself prevent duplicate ledger writes. Two workers can pick up the same event, or a worker can crash mid-transaction and retry. The worker's ledger write needs its own idempotency guard, and the inbox needs a way to mark entries processed.

What the ledger write needs from the database

PostgreSQL's documentation supplies the facts to check the ledger side. Read Committed is the default isolation level in PostgreSQL, and at that level two successive SELECT commands inside a single transaction can see different data if other transactions commit between them. The isolation table lists serialization anomaly as possible at Read Committed. The explicit locking chapter says lock modes can be used for application-controlled locking in situations where MVCC does not give the desired behavior, that UPDATE, DELETE, INSERT and MERGE acquire a ROW EXCLUSIVE lock on the target table, and that two transactions cannot hold locks of conflicting modes on the same table at the same time.

The design inference: under Read Committed, the isolation level alone does not stop two workers from acting on state that changes between their reads. You must add a mechanism, most directly a unique constraint on the provider event ID at the ledger, or an explicit lock that serializes the check-and-write. PostgreSQL's documentation describes PostgreSQL; if your ledger runs elsewhere, verify the equivalent guarantees in your database's documentation.

Who owns each step, and what evidence settles it

The workstream has five steps. The following assignments are proposed, not findings about your organization; adjust them, but write down an owner for each before you staff.

The endpoint and its 2xx boundary belong to the service team that runs the consumer. The evidence that settles it is a load test of acknowledgement latency under realistic event volume, plus a written statement of which design you chose. The durable inbox belongs to the same team. The evidence is a crash test: kill the endpoint after the write and confirm the message survives and the provider's event is not lost. The idempotent worker belongs to whoever owns the payments pipeline behind the endpoint. The evidence is a test that runs two workers on one event and produces one ledger entry. The ledger transaction, with its documented isolation level and lock scope, belongs to whoever owns the ledger schema. The evidence is that documentation, citing your database's manual, plus the two-worker test result. Reconciliation, when events and ledger disagree, belongs to one named person, not a rotation. The evidence is a reconciliation run whose counts match and a written procedure for when they do not.

How to staff the work

Two models fit this workstream, priced separately. If nobody on your side reviews code and plans releases, the managed team is the option that puts delivery ownership with Atom: a dedicated team run by our tech lead, where you own the priorities and Atom owns delivery. The tech lead talks with you every day, turns priorities into a plan, owns code review, quality and releases, and manages the engineers. Published prices per team per month are 29,500 USD for Starter, 44,500 USD for Core and 67,500 USD for Plus; an engineer added to a managed team is 10,900 USD senior or 8,000 USD mid. Ending it takes 30 days' notice to remove one person and 60 days to end the team.

Developers in your team is the other model, the one buyers call staff augmentation. Our engineers join your standups, tools and repositories and take direction from your engineering manager, so you direct the work and own delivery quality. Published prices per developer per month are 7,000 USD mid, 9,500 USD senior, 11,500 USD senior data or AI, 12,500 USD lead and 6,500 USD QA automation, with a 3-month initial term and then 30 days' notice to end. If you have no written scope, the Blueprint is a two-week fixed-price engagement at 7,500 USD that delivers the scope, architecture, milestone plan, team plan and a fixed monthly quote.

When the recommendation changes

The default recommendation above is the inbox design, as a labeled inference. Design A is a conditional alternative, and these are proposed decision rules, not findings about your setup. Consider Design A when the ledger write is demonstrably fast, a single writer handles the event type, and you have measured acknowledgement latency under load. Keep Design B when the provider's retry schedule is aggressive relative to your ledger's worst case, when the ledger is shared with other writers, or when you need the inbox as an audit record anyway. The staffing recommendation follows the same conditions: a managed team suits the case where the boundary, worker and reconciliation need one accountable owner of delivery; developers in your team suit the case where your engineering manager already owns the payments domain and needs capacity.

Checks

  1. Write down which design you chose, and confirm the endpoint returns 2xx only at that boundary; this is a proposed check, not a documented requirement.
  2. Check whether your provider's documentation specifies its retry schedule and timeout, and whether a 2xx stops retries for an event.
  3. Test the proposed unique constraint on the provider's event ID at the ledger, including a run with two workers on one event.
  4. Document the ledger transaction's isolation level and lock scope, citing your database's documentation.
  5. Name one owner for each of the five steps, including reconciliation, before you staff the workstream.

Questions

Does a durable inbox alone stop duplicate ledger entries?

No. The inbox separates acknowledgement from processing, but the worker still needs an idempotency guard at the ledger, such as a unique constraint on the provider event ID. That mechanism is proposed, not documented by the sources; test it against your own schema and pipeline.

Which isolation level should the ledger transaction use?

Document the level and the lock scope, whatever you choose. PostgreSQL's default is Read Committed, where the documentation lists serialization anomalies as possible, so check whether a uniqueness rule or an explicit lock covers the check-and-write. Verify the equivalent in your own database's documentation.