Skip to content
masterclass Buddy

FastAPI · Function

Cookie

FastAPI can read request cookies with Cookie(). Declare the cookie as a typed parameter, and use a default such as None when it is optional.

Last updated

Syntax

parameter: Annotated[type, Cookie()] = default

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Query
  • Path
  • Response
  • Pydantic BaseModel
  • Cookie parameter models

Source: Cookie Parameters - FastAPI. Checked 2026-11-03.