Skip to content

Idempotence

Greg Swindle edited this page Sep 4, 2017 · 1 revision

⬅️ Resource Naming | HTTP Status Codes ➡️

What Is Idempotence?

Idempotence is a funky word that often hooks people. Idempotence is sometimes a confusing concept, at least from the academic definition.

From a RESTful service standpoint, for an operation (or service call) to be idempotent, clients can make that same call repeatedly while producing the same result. In other words, making multiple identical requests has the same effect as making a single request. Note that while idempotent operations produce the same result on the server (no side effects), the response itself may not be the same (e.g. a resource's state may change between requests).

The PUT and DELETE methods are defined to be idempotent. However, there is a caveat on DELETE. The problem with DELETE, which if successful would normally return a 200 (OK) or 204 (No Content), will often return a 404 (Not Found) on subsequent calls, unless the service is configured to "mark" resources for deletion without actually deleting them. However, when the service actually DELETEs the resource, the next call will not find the resource to DELETE it and return a 404. However, the state on the server is the same after each DELETE call, but the response is different.

GET, HEAD, OPTIONS and TRACE methods are defined as safe, meaning they are only intended for retrieving data. This makes them idempotent as well since multiple, identical requests will behave the same.

⬅️ Resource Naming | HTTP Status Codes ➡️


Creative Commons License This work by RestApiTutorial.com is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.


APIs and SDKs (v1.0.0)

  1. Party: an identifiable, addressable entity that may have a legal status and that normally has autonomous control over (at least some of) its actions.
  2. Money: represents an amount of a specific Currency.

Tools

  1. swagger-codegen: servers compared

References

  1. HTTP Status Codes
  2. MDA Guide rev. 2.0
  3. REST Tutorial

Product delivery roadmap

  1. Epics (all archetypes Projects)
  2. MVPs (all archetypes Milestones)
  3. Issues (all, open)
Clone this wiki locally