REST API Design Best Practices

Chapter 2 · Practice 1 of 4

Respect what safe and idempotent mean

From HTTP methods and their promises

Why it matters

RFC 9110 gives each method properties that clients, proxies and caches rely on:

MethodSafeIdempotentTypical use
GET, HEADYesYesRead
QUERYYesYesRead with a query in the body
PUTNoYesCreate or replace at a known URL
DELETENoYesRemove
POSTNoNoCreate in a collection, run an action
PATCHNoNo (unless designed to be)Partial update

Safe means the client does not request a state change: crawlers, prefetchers and link previews call GET freely. Idempotent means sending the request twice has the same effect as once, so clients and proxies may retry it after a dropped connection.

A GET /orders/7/cancel breaks both promises: a link preview could cancel the order.