Idempotency-Key Write Path Design Prompt
Design an idempotency-key scheme for an automation that makes external write calls — key derivation, store, conflict handling, and TTL — so retries, replays, and concurrent runs cannot create duplicate orders, charges, tickets, or resources.
- Target user
- Engineers building automation that calls external write APIs
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior automation engineer who has debugged a double-charge caused by a retry on a request that actually succeeded, and now designs idempotency in from the start. I will provide: - The write operation the automation performs and the downstream API it calls - Whether that API supports idempotency keys natively, and its semantics if so - How the automation is triggered and whether it can run concurrently - The consequence of a duplicate write (charge, resource, ticket, message) Your job: 1. **Key derivation** — define how the idempotency key is computed from stable, deterministic input (not a timestamp or random per-attempt value) so all retries of the same logical operation share one key. 2. **Store design** — design the idempotency store (key, status, result, created-at), how it is written before the call, and how it survives process restarts. 3. **Request lifecycle** — specify the state machine: reserve key → call downstream → record result, and how a crash between call and record is reconciled. 4. **Conflict handling** — define behavior when a key already exists: return the stored result, wait on an in-flight key, or reject a different payload reusing the same key. 5. **Downstream native keys** — if the API supports idempotency keys, map your key to it and reconcile your store with the provider's result rather than double-tracking. 6. **TTL and cleanup** — set a key TTL long enough to cover all retries/replays but bounded, and define what re-running after expiry means. 7. **Concurrency** — handle two concurrent runs racing on the same key with a lock or atomic insert so only one performs the write. Output as: the key-derivation rule, the store schema, the request-lifecycle state machine, the conflict-resolution table, and the TTL/concurrency strategy. Require that the key be reserved before the downstream call and reconciled after a crash, and that no different payload be allowed to reuse an existing key without an explicit, reviewed override.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Outbound Webhook Dispatcher with Backoff Design Prompt
Design the sender side of a webhook system — a dispatcher that delivers events to customer endpoints with bounded retries, exponential backoff with jitter, per-endpoint circuit breaking, and a dead-letter path — so a slow or flapping receiver cannot cause a retry storm or unbounded queue growth.
-
Webhook-to-Action Event Automation Design Prompt
Design an event-driven automation that turns an inbound webhook into a safe, bounded action — covering authentication, idempotency, allow-listing of which events may trigger which actions, and a read-only default so a spoofed or replayed event can never cause harm.
-
Idempotency Receipt Store Design Prompt
Design an idempotency receipt store that records the result of each first-time request keyed by an idempotency key, so retries return the original outcome instead of re-executing the side effect.
-
StackStorm Sensor Event Detection Design Prompt
Design a StackStorm sensor that detects external events reliably — tracking what it has already seen, recovering missed events on restart, and emitting clean triggers so rules don't fire twice or miss events.
More Automation prompts & error guides
Browse every Automation prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.