Sobes.tech
Middle

Which HTTP methods are idempotent and which are not?

sobes.tech AI

Answer from AI

Idempotent HTTP methods are those that can be called multiple times in succession without changing the result after the first call.

Idempotent methods:

  • GET — retrieve a resource, does not change the server state.
  • PUT — update a resource, repeated calls with the same body will yield the same result.
  • DELETE — delete a resource, repeated calls will not change the result (resource already deleted).
  • HEAD — like GET but without a response body.
  • OPTIONS — request supported methods.

Non-idempotent methods:

  • POST — create a resource or perform an operation, each call may create a new resource or change the state.

Example:

  • Calling PUT /user/123 with the same data multiple times will not change the user's state after the first update.
  • Calling POST /orders multiple times will create multiple orders.
Which HTTP methods are idempotent and which are not… - sobes.tech