Make a job or webhook safe to retry
Prompt that protects a job or webhook against double execution with an idempotency key, clear states and retry rules. Paste it into an AI tool of your choice, which then makes retries safe.
- Topic
- Apps & prototypes
- Type
- Prompt
- Level
- Advanced
- Time
- about 10 min
Results depend on the tool, the model and what you enter.
Result preview
Example: written by our editors, not real AI output.
Risk: the payment provider resends the same event if we do not reply within 10 seconds. Key: provider event ID, unique index in table "processed_events", kept for 30 days States: received → processing → done / failed Repeat while "done": return 200 at once, book nothing Retries: only timeouts and 5xx, at most 5, growing delay with jitter, then to the failed-jobs list Tests: send the event twice; abort after booking; two deliveries at the same time Assumption: the database supports transactions.
Fill in
What you type stays in this browser window. We store and send nothing.
- payment provider webhook books a payment
- job sends invoices by email
- import creates orders from the shop
- job pulls data from a partner API
- endpoint creates a customer account
- payment is booked twice
- customers get the same email twice
- order appears twice in the warehouse
- counters are increased twice
- two accounts with the same email address
- Python with PostgreSQL and a job queue
- Node.js with Redis
- Java with Spring and Kafka
- PHP with MySQL and cron jobs
- Go with a cloud message queue
Your prompt
You have edited the prompt. Changes in the fields above no longer overwrite it.
This is an instruction for an AI, not the result itself.
Where this prompt works
These AI tools are a good fit for this prompt:
How to use it
- Fill in the fields or tap a suggestion. Leave out names, addresses and other personal data.
- Copy the finished prompt into an AI tool of your choice.
- Before going live, deliberately feed duplicate events and interruptions into a test environment and check that every effect happens exactly once.
Why does this work?
When in doubt, networks and queues deliver twice rather than not at all. A key plus clear states turn "hopefully only once" into a testable "takes effect exactly once".
Tips
- Store the key in the same transaction as the actual change, otherwise there is a gap between the two.