Quick guide to standard HTTP methods, their semantics, and when to use each in REST APIs and web apps.
| Method | Safe | Idempotent | Request Body | When to Use |
|---|---|---|---|---|
GET |
Yes | Yes | No | Retrieve a resource without side effects. Safe to cache, bookmark, and retry. |
HEAD |
Yes | Yes | No | Same as GET, but returns only headers (no body). Useful to check existence, Content-Length, or Last-Modified. |
POST |
No | No | Yes | Create a new resource or trigger a non-idempotent action (e.g. submit form, start job). |
PUT |
No | Yes | Yes | Replace an entire resource at a known URI (or create it if absent). Repeating the same PUT produces the same state. |
PATCH |
No | No* | Yes | Apply a partial update to an existing resource. (*Can be idempotent depending on payload.) |
DELETE |
No | Yes | Optional | Delete the target resource. Repeating DELETE leaves the resource deleted. |
OPTIONS |
Yes | Yes | No | Describe communication options for the target resource; used by browsers for CORS preflight requests. |
CONNECT |
No | No | No | Establish a tunnel to the server (typically HTTPS via HTTP proxy). |
TRACE |
Yes | Yes | No | Loop-back diagnostic test along the path to the target resource (usually disabled in production). |
HTTP methods (defined in RFC 9110) communicate the client's intended action on a target resource. Choosing the right method in REST APIs and web applications is not just a style convention - proxies, CDNs, browsers, and retry middleware rely on these guarantees to decide whether a request can be cached, prefetched, or safely retried on network failure.
GET, HEAD, OPTIONS): Must not alter server state (read-only). Search crawlers and browser link prefetchers assume GET requests have no destructive side effects, which is why logout or delete actions should never use GET.GET, HEAD, PUT, DELETE, OPTIONS): Executing the exact same request multiple times produces the same final resource state as executing it once. For example, PUT /users/42 replaces user 42 with the same payload every time, whereas POST /orders creates a new order on each call.GET, HEAD): Responses can be stored by browsers and CDNs when accompanied by Cache-Control or ETag headers.PUT vs. PATCH vs. POST (FAQ)PUT vs. PATCH? Use PUT when the client sends the complete replacement representation of a resource at a known URI (missing fields are reset or rejected). Use PATCH when sending only the changed fields (partial update), such as updating a user's email without resending their full profile.OPTIONS appear in browser Network tabs? Browsers automatically send a CORS preflight OPTIONS request before cross-origin PUT, DELETE, or application/json POST requests to verify Access-Control-Allow-Methods.HEAD used for? HEAD returns the exact same status code and headers as GET (including Content-Length and Last-Modified) without transferring the response body - ideal for checking file sizes or link availability.When designing predictable REST endpoints, pair the right HTTP method with accurate status codes: return 201 Created with a Location header from POST when creating a new resource, 200 OK or 204 No Content from PUT, PATCH, and DELETE, and 405 Method Not Allowed (with an Allow header) when a client sends an unsupported verb to a valid endpoint. Avoid tunneling actions like POST /getUsers or GET /deleteUser?id=5, because HTTP caches, retries, and security scanners expect verbs to match their RFC semantics.