Content-Type
The header that states what format a message body is in, such as application/json.
In more detail
Whoever sends a body sends Content-Type, so it appears on requests with bodies and on responses. It is a statement of fact about the bytes present, while Accept is the caller’s wish list. A new format, such as newline-delimited JSON for a stream, needs its own content type so the client knows how to read it.
Examples
application/problem+json for Problem Details errorstext/event-stream for Server-Sent EventsContent-Type: application/jsonKafka record header: ('content-type', b'application/json')Related terms
- Accept header — The request header in which a client lists the formats it can read, such as Accept: application/json.
- media type — A standard label for a data format, written type/subtype, such as application/json or text/event-stream.
- content negotiation — The way a client and server agree on the format, language or compression of a response using request headers such as Accept.
- HTTP header — A named line of metadata in an HTTP message, such as Content-Type: application/json, that describes the body, the caller or how to handle the exchange.
- Problem Details — A standard JSON shape for HTTP error responses, defined in RFC 9457, with members such as type, title, status, detail and instance.
- Server-Sent Events — A standard way for a server to keep an HTTP response open and push a stream of text events to the client, in one direction only.
- record header — A key and bytes-value pair attached to a record outside its value, used for metadata such as content type or a trace ID.
- JSON — A simple text format for structured data made of keys, values, lists and nested objects.
- HTTP — The protocol web browsers and web servers use to send requests and responses.
Taught in
- What An API Is, And The Alternatives — Modern API Architecture: REST, GraphQL & gRPC
- Headers And Content Negotiation — Modern API Architecture: REST, GraphQL & gRPC
- Large Payloads And Streaming — Modern API Architecture: REST, GraphQL & gRPC
- Resilient Error Handling: Problem Details & Envelopes — Production Full-Stack Engineering
- Server-Sent Events: Streaming Updates & Recovery — Production Full-Stack Engineering
- Implementing An OpenAPI Contract — Modern Java: Virtual Threads & High-Throughput Services
- Testing APIs With MockMvc — Modern Java: Virtual Threads & High-Throughput Services
- Headers, Envelopes And Event Metadata — Apache Kafka & Event Streaming
- Streaming Endpoints: Server-Sent Events & NDJSON Feeds — Next.js 15 & Modern App Router Architecture
- Native HTTP Server: Request & Response Lifecycles — Node.js Internals & Backend Services
- Native HTTP/2 Protocols: Multiplexed Streams & Push — Node.js Internals & Backend Services