- Class
- 4xx client error
- Defined in
- RFC 9110, section 15.5.6
- Retry
- No
- Key header
- Allow
- Cacheable by default
- Yes
When your API should return 405
Return 405 when the path is valid and the method isn’t one it supports. RFC 9110 requires an Allow header listing the methods that are supported, like Allow: GET, POST, so a client can correct the call without reading the docs.
If the method is supported and this caller can’t use it, that’s a 403. If your server doesn’t implement the method anywhere, like a custom method it has never heard of, that’s a 501.
How public APIs declare 405 in their OpenAPI specs
Only three of the eleven public specs we score declare a 405, as they were on 4 December 2026. Box does on 32 operations, GitHub on 5 and SendGrid on 3.
None of those 40 declarations documents the Allow header that RFC 9110 requires with every 405.
| API | Operations | Declare 405 | With Allow | How errors are described |
|---|---|---|---|---|
| Box | 297 | 32 | 0 | Per status code, plus a default |
| GitHub | 1,288 | 5 | 0 | Per status code |
| SendGrid Mail | 3 | 3 | 0 | Per status code |
| Stripe | 612 | 0 | 0 | One default error response |
| OpenAI | 406 | 0 | 0 | Per status code |
| Plaid | 351 | 0 | 0 | One default error response |
| Asana | 302 | 0 | 0 | Per status code |
| Twilio | 197 | 0 | 0 | No error responses |
| Slack | 174 | 0 | 0 | One default error response |
| Adyen Checkout | 28 | 0 | 0 | Per status code |
| Swagger Petstore | 19 | 0 | 0 | Per status code, plus a default |
Counted per operation from each vendor’s public OpenAPI document on 4 December 2026.
Declare 405 in your OpenAPI spec
Most specs only list the methods a path supports, so a 405 is implied everywhere else. Where you declare one, add Allow, which is the part a client can act on. It can change with the resource’s state.
paths:
/invoices/{invoiceId}:
delete:
operationId: deleteInvoice
responses:
"204":
description: The invoice was deleted.
"405":
description: Paid invoices can't be deleted.
headers:
Allow:
description: The methods this invoice accepts now.
schema:
type: string
example: GET, PATCHWhat an Octri SDK does with a 405
A 405 has no error class of its own in an Octri SDK. The caller gets an SdkHttpError with statusCode 405 and the response headers, Allow included, and the SDK doesn’t retry it.
A generated SDK only calls the methods your spec declares, so a 405 reaching it usually means the spec and the server disagree. That’s worth a contract test in CI more than a catch block.
import { Acme, SdkHttpError } from "acme-sdk";
const acme = new Acme({ apiKey: process.env.ACME_API_KEY });
try {
await acme.invoices.delete({ invoiceId: "inv_123" });
} catch (err) {
if (err instanceof SdkHttpError && err.statusCode === 405) {
console.log(err.headers["allow"]); // "GET, PATCH"
}
throw err;
}More on retries and typed errors in SDK error handling.
HTTP 405 questions
Is 405 right for a read-only API key?
No. The method is supported and this key can’t use it, which is a 403. A 405 should depend on the resource alone, and the same request with an admin key would get the same answer.
Does a 405 need a body?
No. The Allow header carries what the client needs. A short JSON error naming the refused method still helps whoever reads the logs.
Should OPTIONS return the Allow header too?
Yes. RFC 9110 says a server should describe the methods it supports in response to OPTIONS, and Allow is the usual way. Browsers’ CORS preflight uses its own Access-Control-Allow-Methods header.