Skip to content

By the Octri team · Updated

415 Unsupported Media Type

Share

A 415 means the server won’t accept the request body in the format it was sent. Usually the `Content-Type` header is missing or wrong, like form data sent to an endpoint that only reads JSON.

All HTTP status codes

Class
4xx client error
Defined in
RFC 9110, section 15.5.16
Retry
After fixing Content-Type
Key header
Content-Type
Cacheable by default
No

When your API should return 415

Return 415 when the request’s Content-Type isn’t one the endpoint accepts, or when Content-Encoding names a compression it doesn’t support. Say which types it does accept, in the body and, for PATCH, in an Accept-Patch header.

If the type is right and the body doesn’t parse, that’s a 400. If the problem is the response format the client asked for in Accept, that’s a 406 Not Acceptable.

How public APIs declare 415 in their OpenAPI specs

One of the eleven public specs we score declares a 415, as they were on 4 December 2026, on a single Box operation.

Every OpenAPI 3 spec does list the media types each request body accepts, under requestBody.content, which tells a client what to send before a 415 can happen. That’s the part generators read.

APIOperationsDeclare 415How errors are described
Box2971Per status code, plus a default
GitHub1,2880Per status code
Stripe6120One default error response
OpenAI4060Per status code
Plaid3510One default error response
Asana3020Per status code
Twilio1970No error responses
Slack1740One default error response
Adyen Checkout280Per status code
Swagger Petstore190Per status code, plus a default
SendGrid Mail30Per status code

Counted per operation from each vendor’s public OpenAPI document on 4 December 2026.

Declare 415 in your OpenAPI spec

Name each accepted type under requestBody.content, and declare the 415 for clients that send anything else.

yaml
paths:
  /invoices:
    post:
      operationId: createInvoice
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/InvoiceInput"
      responses:
        "201":
          $ref: "#/components/responses/InvoiceCreated"
        "415":
          description: Send the body as application/json.

What an Octri SDK does with a 415

An Octri SDK sets Content-Type from the media type your spec declares for the request body, so a generated client sends the right header on every call.

If a 415 arrives anyway, the caller gets an SdkHttpError with statusCode 415, which isn’t retried. It usually means a proxy or a piece of middleware changed the body or its headers on the way.

typescript
import { Acme, SdkHttpError } from "acme-sdk";

const acme = new Acme({ apiKey: process.env.ACME_API_KEY });

try {
  await acme.invoices.create({ customerId: "cus_123", amount: 4200 });
} catch (err) {
  if (err instanceof SdkHttpError && err.statusCode === 415) {
    // Something between the SDK and your API rewrote Content-Type.
    console.log(err.requestId);
  }
  throw err;
}

More on retries and typed errors in SDK error handling.

HTTP 415 questions

Does a missing Content-Type cause a 415?

Often, yes. Some servers assume JSON when the header is missing and others refuse. A spec that declares the type lets clients send it every time.

Is the charset part of the media type check?

Partly. application/json; charset=utf-8 and application/json name the same type, so a server should accept both. RFC 8259 defines JSON as UTF-8.

Should a 415 list the accepted types?

Yes. Put them in the error body. For PATCH, RFC 5789 defines Accept-Patch for exactly this.

Share