Agent Wranglers

Transactions and concurrency Required

Make writes safe to repeat

Let clients retry a write without doing it twice. Networks fail after the server has acted, so retries will happen.

How to do it

Accept an idempotency key from the client for writes such as payments and orders. Store it with a unique constraint and the result. When the same key returns, send back the stored result instead of acting again. The API playbook's idempotency key rule covers the header and expiry.

How to check

Send the same order twice with one idempotency key. One order exists, and both replies are the same.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers data playbook: https://agentwranglers.se/playbook/data/transactions-and-concurrency/idempotent-writes.