Content-Type Header
Pronunciation: KON-tent type HED-er
Also known as: HTTP Content-Type Header, Media Type Header
Definition
Content-Type Header is an HTTP representation header that identifies the media type and relevant parameters of the message body being sent. Content-Type states what the current body is, while Accept describes which response formats the client prefers. The principal risks include parser confusion, incorrect deserialization, content sniffing, signature mismatch, unsupported formats accepted silently, and security controls applied to a different interpretation of the body.
Overview
Meaning and scope
Content-Type Header is an HTTP representation header that identifies the media type and relevant parameters of the message body being sent. Content-Type states what the current body is, while Accept describes which response formats the client prefers. The principal risks include parser confusion, incorrect deserialization, content sniffing, signature mismatch, unsupported formats accepted silently, and security controls applied to a different interpretation of the body.
Mechanism and operation
The Content-Type Header contract should define identifiers, validation, authorization, status semantics, errors, limits, and version behavior at the same boundary. A production implementation should send an explicit supported media type, validate it before parsing, define charset behavior where relevant, reject conflicting bodies, and ensure signatures are calculated over the exact representation. For Content-Type Header, the application should preserve a correlation path from request construction through response, asynchronous completion, and final business state. Useful measures include unsupported-media-type responses, parsing errors, missing-header rate, signature failures by media type, and client usage by content type. Changes to Content-Type Header should be checked against older clients, stored payloads, enum growth, default behavior, and retry assumptions.
Practical payment example
An API endpoint expecting JSON rejects a request with an incompatible content type before parsing amounts or payment instructions.
Operational checks
Observability for Content-Type Header should record operation, version, principal, request ID, latency, retry count, error code, and final state without exposing secrets. Testing Content-Type Header should cover malformed input, denied access, rate limits, timeouts, duplicates, asynchronous completion, and version changes. The Content-Type Header owner should publish stable error semantics and guidance on whether correction, retry, status lookup, or escalation is appropriate.
Distinctions and limits
Send an explicit supported media type, validate it before parsing, define charset behavior where relevant, reject conflicting bodies, and ensure signatures are calculated over the exact representation.
Related reading
Related definitions: Accept Header, Payload Signature.
Example
An API endpoint expecting JSON rejects a request with an incompatible content type before parsing amounts or payment instructions.
Comparison
The principal risks include parser confusion, incorrect deserialization, content sniffing, signature mismatch, unsupported formats accepted silently, and security controls applied to a different interpretation of the body.
Key Takeaway
Send an explicit supported media type, validate it before parsing, define charset behavior where relevant, reject conflicting bodies, and ensure signatures are calculated over the exact representation.
Sources
- HTTP Semantics — IETF (2026-08-03)
- OpenAPI Specification — OpenAPI Initiative (2026-08-03)
- OWASP API Security Top 10 - 2023 — OWASP (2026-08-03)