ASP.NET Core Web API Interview Question #12
What does idempotent mean in HTTP API design?
Web API & REST Fundamentals, Controllers, HTTP Methods & Status Codes Junior Beginner
Quick Interview Answer
An operation is idempotent when repeating the same request has the same intended effect on server state as performing it once. GET, PUT, and DELETE are defined with idempotent semantics, while POST is not inherently idempotent.
Detailed Explanation
An operation is idempotent when repeating the same request has the same intended effect on server state as performing it once. GET, PUT, and DELETE are defined with idempotent semantics, while POST is not inherently idempotent.
Idempotency matters for retries. For critical POST operations such as payments or order creation, APIs may implement idempotency keys so a retried request does not accidentally create duplicate effects.
Code Example
PUT /api/products/10
DELETE /api/products/10
// Repeating the same intended operation should not
// create additional state changes beyond the first effect.