HTTP Methods Cheatsheet - REST/HTTP Verbs & Idempotency
When designing REST APIs you often wonder PUT vs PATCH, or which is idempotent. Grouped by method semantics, idempotency, safe attributes and status-code pairing, with copy-ready examples.
Back to ReferenceCore Methods 7
GETGet资源,安全且幂,不应有副作用
POSTCreate子资源or提交处理,非幂
PUT完整Replace资源,幂(重复request结果一致)
PATCH部分Update资源,通常不幂(除非语义保证)
DELETEDelete资源,幂(多次删结果一致)
HEAD同 GET 但只返回头,用于探活/cache校验
OPTIONS查询目标supports的通信选项,CORS 预检用
Idempotency & Safety 4
安全方法GET、HEAD、OPTIONS(不改变Service器state)
幂等方法GET、PUT、DELETE、HEAD、OPTIONS
非幂等POST、PATCH(默认不保证重复request一致)
Idempotency-KeyPOST 重试时用request头键避免重复Create
Status Pairing 6
GET → 200 / 304成功or命中cache
POST → 201 / 202Create成功or已接收async处理
PUT → 200 / 204Replace成功,可返回新资源or空
PATCH → 200 / 204部分Update成功
DELETE → 204 / 200Delete成功,无内容or返回摘要
方法不允许 → 405对只supports GET 的interface发 POST
Common Mistakes 4
用 GET 改状态违反安全语义,爬虫/预取会误触发副作用
PUT 当 PATCH 用PUT 需传完整资源,缺field会被清空
POST 重复提交无幂键时重试会Create重复资源
DELETE 返回 200 带正文更规范是 204 No Content
REST Design Conventions 6
GET /userslist资源(set)
GET /users/1单个资源(子资源)
POST /usersCreate资源
PUT /users/1整体ReplaceUser 1
PATCH /users/1局部UpdateUser 1
DELETE /users/1DeleteUser 1
💡 Tips
- PUT sends the full resource — missing fields get cleared; use PATCH for partial updates.
- GET/HEAD/OPTIONS are safe methods — never change server state inside them.
- Retrying POST needs an Idempotency-Key, or you may create duplicate resources.
- The HTTP Status Codes sheet is provided separately; use both when designing APIs.
Official References
Commands are compiled from the official docs below. Click to verify the latest usage.
Maintained by LaoHand
Publicly updated on Aug 2, 2026, continuously proofread against official docs.
Found an error? Report it
Wrong command or description? Open an issue to help us fix it.
Found an error? Report it