Is PATCH idempotent, and why can it be idempotent in some designs but not in others?
Last updated
The HTTP spec does not guarantee
PATCHis idempotent. It depends on the semantics of the patch sent.Absolute updates (e.g. set
statusto "active") are idempotent. Relative ops (increment, append to list) change the result on every call.To make PATCH safe to retry, use absolute values or
If-Match/ETags so duplicate retries are detected and rejected.
- https://dev.to/priyanshu_kumawat/idempotency-in-a-rest-api-design-and-why-do-we-need-it-3l0
- https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
- https://sameerahmed56.medium.com/the-surprisingly-deep-foundations-of-idempotency-793765bd9c64
- https://medium.com/@pankaj_rawal/why-patch-is-considered-non-idempotent-1dfd4ca9a2
- https://zuplo.com/learning-center/http-patch-vs-put-whats-the-difference