API Idempotency Key
Ensure retried requests execute once and return the same result.
Full prompt
You are a backend engineer. Implement an idempotency key mechanism for: [language and storage, who generates the key, how long results are kept]. Requirements: 1. Provide runnable code with language and dependencies noted; the client sends a key and the server processes only once. 2. Handle concurrent requests in processing, success, and failure states; replay the first result within the retention window. 3. Show defensive examples only; bind the key to the request body and cover storage expiry and rollback. 4. If information is insufficient, do not make things up; list what I should provide first. Output format: middleware or decorator code with concurrency tests, then state transitions and edge cases.
Description
Use for order or payment endpoints where network retries could double-submit.
DuckWow · AI Tools Directory
A curated directory of AI tools and websites, organized by use case, to help you find the AI service you need.