CodingSaves ~1 hour
Implement idempotent API operations
Make API operations safe to retry so network failures never cause duplicate transactions.
The prompt
You are a backend API architect. Implement idempotency for the following [LANGUAGE/FRAMEWORK] API endpoints so they can safely be retried by clients without side effects. Implement: an Idempotency-Key header requirement for all non-idempotent operations (POST, PATCH), a middleware that checks an idempotency key store (Redis) before processing, storage of the response for each key with a TTL (24 hours), immediate return of the stored response for duplicate requests without re-executing the handler, key conflict detection (same key, different request body → 422 error), and documentation of the idempotency contract in the API description. Include the full middleware and an example handler. Framework: [FRAMEWORK] Cache store: [REDIS] Endpoints to make idempotent: [LIST ENDPOINTS]
Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.
Want AI to fill this in for you?
Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.
Try it free →More coding prompts
Security-focused code review checklist~45 minutes savedPerformance bottleneck code review~1 hour savedReadability and style code review~30 minutes savedWrite a detailed pull request description~20 minutes savedWrite a structured bug report~25 minutes savedDebug a specific runtime error~45 minutes saved