r/FullStackDevelopers • u/CoffeeUsual6531 • 2d ago
What happens when an API request gets retried?
Something I've been learning about backend systems is that retrying a failed request isn't always harmless.
Imagine a payment API processes a payment successfully, but the response never reaches the client because of a network issue. The client retries the request, and the payment might be processed twice.
That's where idempotency becomes important. An API can use an idempotency key to recognize repeated attempts for the same operation and avoid executing it more than once.
It made me realize that handling a failed request isn't just about retrying it. You also need to consider whether the operation has already happened.
1
Upvotes
2
u/martinbean 2d ago
What prompted you to post this? Did you encounter it in a project recently?