HTTP

Glossary Term

Idempotent

Learn what idempotent means in HTTP. Understand why GET, PUT, and DELETE are idempotent, why POST is not, and how idempotency affects API design.

1 min read intermediate

TL;DR: An operation that produces the same result whether performed once or multiple times. Enables safe retries in distributed systems when requests fail.

An idempotent operation is one that produces the same result whether you perform it once or multiple times. In HTTP, this means making the same request repeatedly has the same effect as making it just once.

Think of it like a light switch set to “on” - flipping it to “on” once turns the light on, and flipping it to “on” a hundred more times keeps it on. The result is the same.

Idempotency is crucial for reliability in distributed systems. If a request fails or you’re unsure if it succeeded, you can safely retry an idempotent request without worrying about duplicating the action.

Idempotent HTTP methods:

  • GET: Reading data multiple times doesn’t change it
  • PUT: Setting a value to X multiple times still results in X
  • DELETE: Deleting something that’s already deleted has no additional effect
  • HEAD, OPTIONS: Like GET, just retrieving metadata

Non-idempotent HTTP methods:

  • POST: Creating a resource multiple times creates multiple resources
  • PATCH: May or may not be idempotent depending on implementation

The key difference: idempotent operations focus on the final state, not the action itself. DELETE is idempotent because after the first successful delete, the resource is gone - subsequent deletes don’t change that state.

Examples:

  • Idempotent (PUT): PUT /users/42 {name: "Jane"} - sets name to “Jane”, repeating still results in “Jane”
  • Idempotent (DELETE): DELETE /users/42 - deletes user 42, repeating has no additional effect
  • Non-idempotent (POST): POST /orders {item: "book"} - creates a new order each time

Related terms: HTTP Method, HTTP Request, HTTP Response

Frequently Asked Questions

What does idempotent mean in HTTP?

An idempotent operation produces the same result whether executed once or multiple times. Repeating the request has no additional effect beyond the first call.

Which HTTP methods are idempotent?

GET, HEAD, PUT, DELETE, OPTIONS are idempotent. POST and PATCH are not. Idempotent methods are safe to retry on network failures.

Why is idempotency important?

It enables safe retries. If a request times out, you can retry idempotent methods without worrying about duplicate effects like creating multiple records.

Is DELETE always idempotent?

Yes, deleting the same resource multiple times has the same effect: the resource is gone. The first call deletes it, subsequent calls find nothing to delete.

Keep Learning