What is the Accept header?
The Accept request header tells the server which media types (like JSON, XML, or HTML) the client is able to process. It enables content negotiation, allowing the same URL to serve different formats depending on client capability.
API Usage & Best Practices
- Always require it in strict APIs: If your API only supports JSON, validate that the client accepts JSON.
- Fallback gracefully: If the client specifies an Accept value your API cannot satisfy, return a
406 Not Acceptableresponse.
Examples
GET /v1/leads HTTP/1.1Host: api.apiguide.devAccept: application/json