Request bodies with Pydantic in FastAPI
Answer: When you need to send data from a client (let's say, a browser) to your API, you send it as a request body. To declare a request body, you use Pydantic models with all their power and benefits. (S1)
Request vs response
- A response body is the data your API sends to the client. (S1)
- Clients don't necessarily need to send request bodies all the time, sometimes they only request a path, maybe with some query parameters, but don't send a body. (S1)
- Sending a body with a GET request has an undefined behavior in the specifications, nevertheless, it is supported by FastAPI, only for very complex/extreme use cases. (S1)
Field validation
- You can declare validation and metadata inside of Pydantic models using Pydantic's Field. (S2)
- Field works the same way as Query, Path and Body, it has all the same parameters, etc. (S2)
- Pydantic's Field returns an instance of FieldInfo as well. (S2)
Claims
- id: C1 claim: Request bodies are declared with Pydantic models. source: S1 evidence: "To declare a request body, you use Pydantic models with all their power and benefits."
- id: C2 claim: A GET body is undefined behavior. source: S1 evidence: "Sending a body with a GET request has an undefined behavior in the specifications"
- id: C3 claim: Field adds validation inside models. source: S2 evidence: "you can declare validation and metadata inside of Pydantic models using Pydantic's Field."
- id: C4 claim: Field works like Query, Path and Body. source: S2 evidence: "Field works the same way as Query, Path and Body"
Sources
- [S1] Request Body - FastAPI. FastAPI docs. https://fastapi.tiangolo.com/tutorial/body/ . License: MIT (fastapi/fastapi LICENSE; Copyright (c) 2018 Sebastián Ramírez; https://github.com/fastapi/fastapi/blob/master/LICENSE). Accessed 2026-11-04.
- [S2] Body - Fields - FastAPI. FastAPI docs. https://fastapi.tiangolo.com/tutorial/body-fields/ . License: MIT (fastapi/fastapi LICENSE; Copyright (c) 2018 Sebastián Ramírez; https://github.com/fastapi/fastapi/blob/master/LICENSE). Accessed 2026-11-04.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: FastAPI docs, Request Body - FastAPI, MIT (fastapi/fastapi LICENSE; Copyright (c) 2018 Sebastián Ramírez; https://github.com/fastapi/fastapi/blob/master/LICENSE); FastAPI docs, Body - Fields - FastAPI, MIT (fastapi/fastapi LICENSE; Copyright (c) 2018 Sebastián Ramírez; https://github.com/fastapi/fastapi/blob/master/LICENSE).
Cite this
iinventedlight. 2026. "Request bodies with Pydantic in FastAPI." iinventedlight Library, iil:note:hmkycyjz, version of 2026-11-04. https://iinventedlight.com/library/notes/fastapi-request-body/. License: CC-BY-4.0.
@misc{iil_note_hmkycyjz,
author = {{iinventedlight}},
title = {{Request bodies with Pydantic in FastAPI}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/fastapi-request-body/},
note = {Permanent ID iil:note:hmkycyjz. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/fastapi-request-body.md.