HTTP methods: what each one means, and which to allow on a public API
An HTTP method is the verb in a request line: it says what the client wants done with the resource named in the URL. The standard set is small, and two properties of it, safe and idempotent, decide how clients retry, how caches behave and which routes deserve a second look. Most API exposure here comes from methods that are enabled by default and never reviewed.
Quick facts
- Defined in
- RFC 9110, section 9 (HTTP Semantics), plus RFC 5789 for PATCH
- Required of servers
- GET and HEAD for general-purpose servers; every other method is optional (RFC 9110 §9.1)
- Safe methods
- GET, HEAD, OPTIONS, TRACE (§9.2.1)
- Idempotent methods
- PUT, DELETE and the safe methods (§9.2.2)
- Rejecting a method
- 405 with an Allow header (§15.5.6); 501 if the method is not recognised
This page covers the methods themselves. How an API decides who may call them is on API authentication, and the wider picture is on API security.
HTTP methods in RFC 9110
The method is a case-sensitive token (RFC 9110 §9.1), so get is not GET. The table follows the RFC’s own method descriptions and its definitions of safe and idempotent. PATCH is not in RFC 9110; RFC 5789 adds it and states that it is neither safe nor idempotent.
| Method | Purpose | Safe | Idempotent |
|---|---|---|---|
| GET | Transfer a current representation of the target | Yes | Yes |
| HEAD | Same as GET, but without content in the response | Yes | Yes |
| POST | Process the request according to the resource's own semantics | No | No |
| PUT | Replace the target's state with the content sent | No | Yes |
| DELETE | Remove the target's current state | No | Yes |
| CONNECT | Establish a tunnel to the server named by the request target | No | No |
| OPTIONS | Describe the communication options for the target | Yes | Yes |
| TRACE | Loop the request message back, as a diagnostic | Yes | Yes |
| PATCH | Apply a partial modification (RFC 5789) | No | No |
A server that receives a method it does not recognise is told to answer 501 Not Implemented. One it recognises but the target resource does not support gets 405 Method Not Allowed. Both rules are in section 9.1 and section 15.5.6 of the RFC. PUT, PATCH and POST bodies are where mass assignment happens. Methods enabled on old routes are part of shadow APIs.
Safe and idempotent: what the words promise
A method is safe when its defined semantics are read-only: the client is not asking for a change of state on the server. RFC 9110 §9.2.1 lists GET, HEAD, OPTIONS and TRACE. The promise is about what the client requests. It does not stop a server from writing a log line, or from doing something harmful behind a GET if a developer built it that way. The RFC says as much, and that is where trouble starts.
A method is idempotent when sending the same request several times has the same intended effect as sending it once. §9.2.2 gives PUT, DELETE and every safe method. POST is not on the list, which is why a client that times out after a payment POST cannot simply resend it. The RFC notes that this property is what lets a client retry automatically after a connection fails; for POST, the API has to supply its own protection, such as a key that identifies the attempt.
Two cautions. Idempotent describes the intended effect, not the response: the second DELETE of a record may well return 404. And the properties describe the method’s definition, not your code. An endpoint that deletes data on GET is still a GET, and every prefetcher, crawler and link preview is entitled to treat it as safe.
Which methods a public API should allow
The short rule, which the OWASP REST Security Cheat Sheet also gives, is an allow-list: name the methods each route accepts and answer the rest with 405. In practice that means deciding per route, not per API, because a collection and a single record take different verbs.
- Read-only routes take GET. Add HEAD if clients check existence or size, and OPTIONS if browsers call the route cross-origin.
- Create routes take POST, usually on the collection.
- Update and delete routes take PUT or PATCH and DELETE, on a single record, and only where the API really offers them.
- TRACE and CONNECT are not used by an ordinary API origin. Leave them off.
The allow-list answers one question: is this verb meaningful here? It does not answer whether this caller may use it on this record. A route that accepts DELETE for every authenticated user is correctly restricted by method and still broken, which is the pattern described on BOLA and listed in the OWASP API Top 10. The same applies to function-level access: the OWASP cheat sheet asks for the caller to be authorised for the method on each resource, not only for the method to be on the list.
Methods that cause trouble
TRACE and CONNECT
TRACE asks the final recipient to send the received request back as the response (RFC 9110 §9.3.8). It exists for diagnosis. The RFC forbids a client to put sensitive data, such as stored credentials or cookies, in a TRACE request, because the response may disclose them. An API has no use for it, and a server that answers it is echoing request headers to anyone who asks.
CONNECT asks a proxy or gateway to open a tunnel to the host named in the request target (§9.3.6). That is the business of proxies. An origin that accepts it is either a proxy by design or misconfigured.
Method override headers
Some clients cannot send PUT, PATCH or DELETE, so frameworks accept a POST carrying a header such as X-HTTP-Method-Override and treat it as the named method. RFC 9110 does not define such a header; it is a convention of individual frameworks. The risk is in the gap it opens: a filter, gateway or route rule that looks at the request line sees POST, while the application acts on DELETE. If you restrict methods in front of the application, switch override off in the application or restrict the header to the routes that need it.
OPTIONS and CORS preflight
OPTIONS describes what a resource supports (§9.3.7). Browsers also send it automatically as a CORS preflight before some cross-origin requests, including those using PUT or DELETE. Blocking OPTIONS across the board therefore breaks browser clients of an API that serves other origins. The matching risk is on the other side: a preflight answer that approves too much. That is covered on CORS misconfiguration.
GET with side effects, and GET with a body
If a GET changes state, an attacker can trigger it from another site with an image tag or a link, using the victim’s own session. That is the shape of CSRF, and moving the action to POST is part of the fix, not all of it. Separately, RFC 9110 §9.3.1 says content sent in a GET request has no generally defined semantics and may cause some implementations to reject the request because of its use in request smuggling. Treat a GET with a body as a request to inspect, not to serve.
Answering the wrong method: 405 and Allow
When the method is known but not supported by the target, RFC 9110 §15.5.6 calls for 405, and the server must send an Allow header listing the methods the resource does support. A route that returns 404, 200 or a generic 500 for a wrong verb hides the mistake from clients and from your own log. Returning 405 with Allow is cheap and makes the allow-list visible: a test that sends each verb to each route and checks the answer is a short script. Where such checks sit in a wider programme is on API security testing.
Do not confuse 405 with 403 or 429. 405 says the verb is wrong for the resource whoever asks; 403 says this caller may not; 429 says too many requests. Clients handle each differently, and a retry loop on 405 only repeats the mistake.
Where a WAF helps and where it does not
A filter in front of the origin sees the method of every request, so an allow-list per route is an honest thing to ask of it: requests with TRACE or CONNECT, or with a verb a route never takes, are easy to recognise and have no legitimate user. That narrows what is exposed while the application is fixed or reviewed.
What the filter cannot see is meaning. It does not know that POST /orders/17/close is destructive and POST /search is not, that your GET handler writes to the database, or that the caller owns record 17. A method override header changes the verb the application acts on after the filter has looked. And a method list says nothing about authorisation. Treat it as one layer, with the application remaining responsible for who may do what.
Roll it out the way any restriction should go in. Record matches first, read what real clients send, and only then refuse. Unusual methods are rare enough that the first week of records usually shows whether a legitimate client uses one; see monitor mode and false positives.
Questions
What are the HTTP methods?
RFC 9110 defines GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS and TRACE. PATCH is added by RFC 5789. Each method tells the server what the client wants done with the target resource.
Which HTTP methods are safe and idempotent?
GET, HEAD, OPTIONS and TRACE are safe, meaning the client does not ask for any state change. PUT, DELETE and the safe methods are idempotent, meaning repeating the request has the same intended effect as sending it once. POST and PATCH are neither.
Which HTTP methods should a public API allow?
Only those each route uses. A read-only route needs GET, with HEAD and OPTIONS if clients rely on them. TRACE and CONNECT have no job on an ordinary API origin. Anything else should get a 405 with an Allow header.
What does 405 Method Not Allowed mean?
The server knows the method but the target resource does not support it. RFC 9110 requires a 405 response to carry an Allow header listing the methods the resource does support.
Can a WAF restrict HTTP methods?
A filter can see the method on every request and compare it with a list per route. It cannot know what an operation means, so a method allow-list narrows exposure but does not replace authorisation in the API. Start in monitor mode.