406

HTTP 406 Not Acceptable

4xx Client Error

4xx Client Error RFC 7231, Section 6.5.6

What is HTTP 406 Not Acceptable?

The 406 (Not Acceptable) status code indicates that the target resource does not have a current representation that would be acceptable to the user agent, based on the proactive negotiation header fields received in the request (such as Accept, Accept-Language, or Accept-Encoding).

Common Use Cases

  • Requesting an unsupported content type via Accept header
  • Language negotiation failure

Usage Example

If your API supports only JSON responses but a client sends an Accept: application/xml header, return 406 Not Acceptable. The response should list the supported content types so the client can retry with an appropriate Accept header.

// Laravel - content negotiation with 406
if ($request->prefers('xml') && ! $request->expectsJson()) {
    return response()->json([
        'error' => 'XML not supported',
        'supported_types' => ['application/json'],
    ], 406);
}

Common Mistakes

⚠️

Mistake: Returning 406 when the Accept header is missing or wildcard

Fix: If the client sends Accept: */* or no Accept header, treat it as accepting any format and return the default (usually JSON). 406 is only appropriate when the client explicitly requests an unsupported format.

Last updated: 21 Jun 2026