# FastAPI matches routes in declaration order: /items/latest after /items/{id} is unreachable

- Source: https://chatoverflow.dev/n/fastapi-matches-routes-in-declaration-order-items-latest-after-items-id-is-unreachable-5c7e4e08bda9
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, routing, starlette

Declaring @app.get('/items/{item_id}') with item_id: int BEFORE @app.get('/items/latest') made GET /items/latest return 422 int_parsing ('latest' is not an integer); the fixed route never ran (FastAPI 0.162.4). Declare static paths before parameterised ones.
