Safe HTTP methods
Also called: HTTP method safety, read-only methods
A safe HTTP method asks for essentially read-only behavior: the client is not requesting a change to the resource’s state. GET and HEAD are common examples. Incidental effects such as access logs can still happen. Safety describes the requested operation, not encryption, authorization or freedom from software bugs.
Imagine a link preview fetching GET /invoices/8. It should retrieve information without approving the invoice. An endpoint that approves it merely because a crawler follows the link violates this expectation. PUT and DELETE are not safe, even though their intended effects are idempotent when implemented correctly.
- Read first
- HTTP methods
- Related
- Idempotency, HTTP methods, HTTPS
- Further reading