# 406 Not Acceptable

> https://http-status.org/docs/406

**Family:** 4xx Client Error

## Rationale

Server cannot produce a response matching the Accept headers.

## In Plain Terms

I can't give you the data in the format you want. I have the data, but not in XML/JSON/etc. that you asked for.

## Description

The HTTP 406 Not Acceptable status code indicates that the target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request.

## Server Perspective

### Usage
- Return 406 when Accept, Accept-Language, or Accept-Encoding excludes every available representation
- Use it when you do not want to fall back to a default representation
- Client requests unsupported response format
- Accept header specifies unavailable content types
- Language negotiation fails
- Encoding negotiation fails

### Implementation
- List the available representations or supported values when that helps the client recover
- Keep 406 distinct from 415, which is about the request payload format

### Common Headers
- No status-specific header is required; still send normal HTTP metadata such as Content-Type, caching, or tracing headers when they help the client.

### Body
- Include available representation formats when that helps the client adjust Accept headers.

### Pitfalls
- Do not use 406 for unsupported request Content-Type
- Do not send 406 if serving a documented default representation is acceptable for your API
- Request media type unsupported (use 415 Unsupported Media Type)
- Resource doesn't exist (use 404 Not Found)
- Bad request format (use 400 Bad Request)

## Client Perspective

### Pitfalls
- Do not interpret 406 as meaning the resource itself is missing

## Examples

### Unsupported response format

API only supports JSON responses, not XML

**Request:**
```
GET https://api.example.test/api/data
Accept: application/xml
```

**Response:**
```
406 Not Acceptable
Content-Type: application/json

{
  "available": [
    "application/json"
  ]
}
```

## Related Codes

- [415 Unsupported Media Type](/docs/415.md)

