HTTP cheatsheet

HTTP: Methods and idempotency

6 common HTTP tasks.

GET: read a resource

Fetches data and must not change anything. It is safe and idempotent, so it can be cached and retried.

GET /users/42

POST: create or trigger something

Sends data to be processed, usually creating a resource. It is not idempotent: repeating it can create duplicates.

POST /users

PUT: replace a resource

Replaces the whole resource at a URL. It is idempotent: repeating it leaves the same result.

PUT /users/42

PATCH: change part of a resource

Applies a partial update to a resource.

PATCH /users/42

DELETE: remove a resource

Deletes the resource. It is idempotent: deleting twice leaves the same state.

DELETE /users/42

HEAD and OPTIONS

HEAD returns only the headers. OPTIONS asks what a server allows, and browsers use it for CORS preflight requests.

HEAD /users/42
OPTIONS /users

Was this page helpful?