The Accept request header indicates which content types (MIME types) the client is able to understand and process in the response.
Syntax and quality values (q-values)
Clients can specify multiple media ranges separated by commas, with optional quality parameters (q) ranging from 0 to 1 representing preference weights:
Accept: application/json, text/html;q=0.9, text/plain;q=0.8, */*;q=0.1
- Default weight: If
qis omitted, the default value is1.0(highest priority). - Specific vs. generic: A more specific media type (e.g.,
application/json) takes precedence over wildcards (*/*).
Accept vs. Content-Type
| Header | Sent In | Role | Example |
|---|---|---|---|
Accept |
Request | Declares what formats the client wants to receive | Accept: application/json |
Content-Type |
Request / Response | Declares what format is currently enclosed in the body | Content-Type: application/json |
If a server cannot provide any representation matching the client’s Accept header, it may return an HTTP 406 Not Acceptable status code.
How to test with curl
Request a specific response representation using curl:
curl -i https://api.example.test/v1/reports/summary \
-H "Accept: application/json"
Key takeaway
The Accept header is a request header used for proactive server content negotiation. It informs the server which MIME types and priorities the client expects in the response payload.