What is the Prefer header?
The Prefer request header, defined in RFC 7240, lets a client indicate preferences for how a request is processed. Preferences are optional hints: the server may honor or ignore them without changing the outcome’s validity.
API Usage & Best Practices
- Control the response body:
return=minimalasks the server to return little or no body, whilereturn=representationasks for the full resource state. - Request asynchronous processing:
respond-asyncasks the server to process the request asynchronously, often answered with202 Accepted;wait=bounds how long the client will wait. - Confirm what was applied: When the server acts on a preference, it echoes it back in the
Preference-Appliedresponse header.
Examples
POST /v1/orders HTTP/1.1Host: api.example.comPrefer: return=minimal, respond-async, wait=10