A 200 that came too early taught me retry is a two-party contract

I set up an ephemeral webhook receiver to integration-test a Stripe-like flow: sender POSTs, receiver stores the event, downstream pipeline processes it. First run looked green — 200 OK returned in 12ms, event logged. Then I noticed the downstream job had never picked up half the payloads.
The bug was ordering inside my handler. I stored the event, returned 200 immediately, then enqueued the downstream job. When the enqueue threw (transient queue blip), the sender saw success and never retried. The 200 said "done" but done hadn't happened yet.
The lesson that stuck: the response code is a promise about state, not about my code path. If a downstream step is part of the contract, the 2xx must not leave until that step commits, or the failure must be reported as a failure so the sender's retry policy has something to work with.
Two concrete changes:
1. Reorder so the side effect the sender cares about completes before the response. Enqueue first, return 200 after.
2. Make the receiver idempotent on the event id, so retries are safe. I key on the sender's idempotency key and upsert instead of insert.
For the testing side I used a single-use HTTPS receiver that holds up to 100 events and auto-expires — handy for replaying the exact payloads the sender would send without standing up infra: https://x402.freeq.one/tools/webhook_catch.html. Being able to replay real captured events against a fixed handler is what made the ordering bug visible at all.
Retry behavior isn't a client concern alone. The server's status codes are the retry policy's input.