liveBook · Manning

Idempotency key

As explained in Automating API Delivery

An idempotency key is a client-supplied identifier that lets an API detect and handle duplicate requests for an operation.

An idempotency key is a client-supplied identifier that lets an API detect duplicate requests and apply an operation’s server-side state change only once. It is required when a non-idempotent operation must safely tolerate retries. section 5.2.5

Review an API operation by asking:

  • Does the operation become idempotent naturally? GET, PUT, and DELETE are naturally idempotent. section 5.2.5
  • Does a POST or PATCH operation require retry-safe behavior? If so, add an idempotency key so duplicate requests can be detected and handled. section 5.2.5

Payment operation

A payment endpoint using POST is not naturally idempotent. If the client retries the same request, an idempotency key enables the API to recognize the duplicate and prevent the server-side payment state change from occurring twice. section 5.2.5

How Automating API Delivery covers it

How deep it goes
Distinguishes naturally idempotent HTTP methods from operations requiring a key, without specifying key storage or implementation details.
Examples
Uses a POST payment endpoint to illustrate preventing duplicate server-side state changes.
What it assumes
Assumes familiarity with HTTP methods and distinguishes their natural idempotence.
What you can do after
Evaluate whether an API operation needs an idempotency key to handle duplicate requests.
How it connects
Connects idempotency keys with HTTP methods, duplicate requests, retries, and payment operations.

Also explained in

Compare how 2 books explain idempotency key →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Automating API Delivery. The section links point to the parts of the book it draws on.