π Quick Navigation
HTTP methods and headers form the vocabulary every API call is built from. Most day-to-day work only touches a handful of each, but knowing the full set makes debugging a strange API response much faster.
HTTP Request Methods
| Method | Purpose | Has a body? | Safe to retry? |
|---|---|---|---|
| GET | Retrieve a resource | No | Yes |
| POST | Create a new resource | Yes | No |
| PUT | Replace a resource entirely | Yes | Yes |
| PATCH | Partially update a resource | Yes | No |
| DELETE | Remove a resource | Usually not | Yes |
| HEAD | Same as GET, but headers only, no body | No | Yes |
| OPTIONS | Ask what methods/headers a server allows | No | Yes |
"Safe to retry" here means idempotent β calling it multiple times has the same effect as calling it once. POST is the odd one out precisely because retrying it can create duplicate resources, which is why a flaky network connection and a POST request are a genuinely risky combination without extra safeguards like an idempotency key.
Common Request Headers
| Header | Purpose |
|---|---|
| Authorization | Credentials, typically Bearer <token> or Basic auth |
| Content-Type | The format of the request body, e.g. application/json |
| Accept | What response format the client wants back |
| User-Agent | Identifies the client application making the request |
| Cookie | Sends previously stored cookies back to the server |
Common Response Headers
| Header | Purpose |
|---|---|
| Content-Type | The format of the response body |
| Set-Cookie | Tells the browser to store a cookie |
| Location | Where to redirect, used with 3xx status codes |
| Retry-After | How long to wait before retrying, common on 429 and 503 responses |
For the status codes that pair with these headers, see our HTTP Status Codes Reference.
CORS Headers
| Header | Purpose |
|---|---|
| Access-Control-Allow-Origin | Which origins are allowed to read the response |
| Access-Control-Allow-Methods | Which HTTP methods are permitted cross-origin |
| Access-Control-Allow-Headers | Which request headers the client is allowed to send |
These headers are set by the SERVER, and enforced by the BROWSER β a mismatch is why an API can work perfectly from a backend script or Postman while failing only when called from a webpage in the browser.
Caching Headers
| Header | Purpose |
|---|---|
| Cache-Control | How long and under what conditions a response can be cached, e.g. max-age=3600 |
| ETag | A fingerprint of the resource, used to check if it changed without resending it |
| Last-Modified | When the resource was last changed |
Cache-Control: max-age=3600, public ETag: "a1b2c3d4"
On a repeat request, the browser can send If-None-Match: "a1b2c3d4" back to the server. If nothing changed, the server replies with a 304 and no body at all, saving the bandwidth of resending identical content.
Common Mistakes
Using POST for every operation regardless of what it actually does is a common REST design mistake β it works, but it throws away the semantic meaning (and the caching and idempotency guarantees) that GET, PUT, and DELETE carry. A well-designed API uses the method that matches the actual operation.
Forgetting to set Content-Type: application/json on a request with a JSON body is another frequent one β some servers infer the format anyway, but plenty don't, and the request body silently fails to parse as JSON on the server side, usually surfacing as a confusing 400 error with no obvious cause.
Frequently Asked Questions
What's the real difference between PUT and PATCH?+
PUT replaces the entire resource with what you send β any field left out is treated as removed. PATCH applies a partial update, changing only the fields included in the request and leaving everything else on the resource untouched.
Is GET allowed to have a request body?+
Technically the HTTP spec doesn't forbid it, but in practice many servers, proxies, and libraries ignore or strip a GET body entirely. Parameters for a GET request belong in the URL's query string, not the body, to guarantee they actually arrive.
Why do I get a CORS error even though my API works fine in Postman?+
CORS is enforced by the browser, not the server or tools like Postman. The browser blocks a cross-origin response unless the server's Access-Control-Allow-Origin header explicitly permits the requesting origin β Postman never applies that browser-side restriction at all.
What does a 304 Not Modified response actually mean?+
It means the browser already has a valid cached copy, and the server is confirming that copy is still current instead of resending the full response body. It's a normal caching optimization, not an error, and it saves bandwidth for content that hasn't changed since the last request.
Which header actually controls how long a browser caches a response?+
Cache-Control, specifically its max-age directive, which sets the number of seconds a response can be reused without asking the server again. The older Expires header does something similar with an exact date, but Cache-Control takes priority when both are present.

