Request body

The request body is the data sent by the client, usually as JSON, with POST, PUT or PATCH. You declare it by annotating a parameter with a Pydantic model; FastAPI reads the JSON, validates it and provides a typed object to the function.

Example

@app.post('/items')
def creer(item: Item):
    return item

Related concepts

The whole glossary