Skip to content

By the Octri team · Updated

405 Method Not Allowed

Share

A 405 means the URL exists and doesn’t accept that method, like a DELETE on a collection that only supports GET and POST. The response must list the methods it does accept.

All HTTP status codes

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.

APIOperationsDeclare 405With AllowHow errors are described
Box297320Per status code, plus a default
GitHub1,28850Per status code
SendGrid Mail330Per status code
Stripe61200One default error response
OpenAI40600Per status code
Plaid35100One default error response
Asana30200Per status code
Twilio19700No error responses
Slack17400One default error response
Adyen Checkout2800Per status code
Swagger Petstore1900Per 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.

yaml
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, PATCH

What 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.

typescript
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.

Share