---
source: https://iinventedlight.com/library/notes/openapi-media-types.md
title: "Declare OpenAPI request and response bodies by media type"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (OpenAPI Initiative); CC0-1.0 (IANA); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: OpenAPI Initiative, OpenAPI Specification; IANA, Media Types. Apache-2.0; CC0-1.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: OpenAPI content maps and IANA media types"
tags: [openapi, media-types, content, requestBody, iana, application/json]
client: Librarian
sources:
  - id: S1
    title: "OpenAPI Specification"
    publisher: OpenAPI Initiative
    url: https://spec.openapis.org/oas/latest.html
    accessed: 2026-11-19
    license: "Apache-2.0"
  - id: S2
    title: "Media Types"
    publisher: IANA
    url: https://www.iana.org/assignments/media-types/media-types.xhtml
    accessed: 2026-11-19
    license: "CC0-1.0"
---
# Declare OpenAPI request and response bodies by media type
**Answer:** OpenAPI describes each HTTP representation under a `content` map. The key is the media type and the value describes it, as a Media Type Object or a Reference Object. Use registered names from the IANA Media Types registry, such as `application/json`. Put that map on a request body or on a response.

## Request bodies and responses

`requestBody` is a Request Body Object or Reference Object, and it is the request body for this operation. It is fully supported in HTTP methods where the HTTP specification has explicitly defined semantics for request bodies. In other cases where the HTTP spec has little to say about message content (such as GET and DELETE), `requestBody` is still permitted, but it does not have well-defined semantics, so avoid it if possible. `responses` is a Responses Object: the list of possible responses as they are returned from executing this operation. A response example in the spec uses `content: application/json:` with a schema reference.

The Components Object can hold reusable Media Type Objects in a `mediaTypes` map. | requestBody | responses |
|---|---|
| `requestBody` | The request body applicable for this operation |
| `responses` | Possible responses as they are returned |
| Parameter `content` | Representations for the parameter; the map MUST only contain one entry |
| Components `mediaTypes` | Reusable Media Type Objects |

## IANA names

The IANA Media Types registry is the list of registered types. `application/json` is registered there (RFC 8259). The same registry also lists `application/json-patch+json`. Use that registered name as the OpenAPI `content` key.

## See also

- [http-status-codes](https://iinventedlight.com/library/notes/http-status-codes/)
- [fastapi-request-body](https://iinventedlight.com/library/notes/fastapi-request-body/)
- [fastapi-response-model](https://iinventedlight.com/library/notes/fastapi-response-model/)

## Claims

- id: C1
  claim: requestBody holds the request body applicable for an operation.
  source: S1
  evidence: "The request body applicable for this operation"

- id: C3
  claim: A content map is keyed by media type and holds Media Type Objects.
  source: S1
  evidence: "The key is the media type and the value describes it"

- id: C4
  claim: IANA registers application/json among other media types.
  source: S2
  evidence: "application/json RFC 8259"

## Sources

- [S1] OpenAPI Specification. OpenAPI Initiative. https://spec.openapis.org/oas/latest.html . License: Apache-2.0. Accessed 2026-11-19.

- [S2] Media Types. IANA. https://www.iana.org/assignments/media-types/media-types.xhtml . License: CC0-1.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: OpenAPI Initiative, OpenAPI Specification; IANA, Media Types. Apache-2.0; CC0-1.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
