← All headersRequest header

What is an Accept header?

Tells the server which media types the client can understand, e.g. application/json or text/html.

Accept is how a browser or API client tells a website up front which response formats it can actually handle, letting a single endpoint serve HTML to a browser and JSON to a script from the same URL. It matters most for APIs practicing content negotiation - and if your uptime monitor sends requests without setting an Accept header the way a real client would, you can end up testing a code path your actual users never hit.

Common use case

A single API endpoint serves either a JSON payload or an HTML-rendered page from the same URL, branching on whether the request's Accept header prefers application/json or text/html.

Example

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

History

Part of the original HTTP/1.0 specification, RFC 1945 (1996), and expanded with quality-value weighting in HTTP/1.1.

Did you know?

The q= values are quality weights from 0 to 1 - a client can rank several acceptable formats in one header instead of just naming a single preferred type.