When the data identifies a specific resource. /users/:id where id is required. Always a string. Convert to ObjectId or number when needed.
Route Params vs Query Params vs Body in Express
When should I use route params in Express?
The answer
More FAQs in Route Params vs Query Params vs Body in Express
Route params identify a resource (in the path, required). Query params filter (after ?, optional). Body sends data for create/update (with express.json, larger). Use each for the right job.
For optional filters, sorting, and pagination. /users?role=admin&limit=10. Always strings. Coerce when needed. Optional, so the endpoint works without them too.
For POST and PATCH where you are creating or updating a resource. Requires express.json middleware. The body can be large and complex. Do not put filters in body of a GET request.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.