REST API Methods and Idempotency

HTTP methods, safe vs unsafe semantics, and idempotency examples for API consumers and designers.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## HTTP method semantics
GET retrieves data
GET /products/sku_123

# Read without changing server state.

POST creates or triggers processing
POST /orders

# Submit a new resource or command-like workflow.

PUT replaces state
PUT /profiles/123

# Send a full replacement representation.

PATCH partially updates state
PATCH /profiles/123

# Send only the fields that change.

DELETE removes a resource
DELETE /profiles/123

# Delete one item by ID.

HEAD fetches headers only
HEAD /reports/monthly.pdf

# Check resource metadata without the body.

OPTIONS advertises supported interactions
OPTIONS /users

# Inspect available methods or CORS capabilities.

## Idempotency patterns
Use an idempotency key for POST
POST /payments
Idempotency-Key: 8f3dc9d4-7d3e-4c66-9f44-7d85f0f86dd1

# Deduplicate retryable create requests.

Client-chosen resource ID via PUT
PUT /devices/device_123

# Make resource creation naturally idempotent.

Use set-style PATCH operations
{
  "display_name": "Jane Smith",
  "timezone": "America/Los_Angeles"
}

# Favor deterministic patches.

Avoid mutations on GET
Avoid: GET /posts/123/mark-read

# Do not track writes in the same endpoint contract.

Recommended next

No recommendations yet.