.NET Architecture & System Design Interview Question #96
What is idempotency in an HTTP API?
Transactions, CQRS, Event Sourcing & Distributed Consistency Mid-Level Intermediate
Quick Interview Answer
An idempotent API operation can be repeated without creating additional unintended effects beyond the first successful application of that logical operation.
Detailed Explanation
An idempotent API operation can be repeated without creating additional unintended effects beyond the first successful application of that logical operation.
GET, PUT, and DELETE are designed to have idempotent semantics when implemented accordingly. For operations such as payment creation, an idempotency key can let the server recognize retries and return the original result instead of charging twice.
Code Example
POST /payments
Idempotency-Key: abc-123
First request -> create payment
Retry -> return same result
do not charge again