What is idempotency and which HTTP methods are idempotent?
Answer
Idempotency means that making the same request multiple times produces the same result as making it once. This is critical for reliable communication over unreliable networks — if a request times out, the client can safely retry an idempotent request without fear of duplicating side effects. GET, HEAD, PUT, DELETE, and OPTIONS are idempotent. POST and PATCH are not inherently idempotent — sending the same POST twice typically creates two resources. However, you can make POST effectively idempotent by requiring an idempotency key header (e.g., Idempotency-Key: UUID), where the server deduplicates requests with the same key. Stripe's payment API is a well-known example that uses this pattern.
Previous
What are the main HTTP methods used in REST APIs and what do they do?
Next
What are the most important HTTP status codes in REST APIs?
More REST API Design Questions
View all →- Beginner What is REST and what are its six architectural constraints?
- Beginner What are the main HTTP methods used in REST APIs and what do they do?
- Beginner What are the most important HTTP status codes in REST APIs?
- Beginner What are REST resource naming conventions?
- Beginner What is the difference between path parameters and query parameters?