Path parameters

A path parameter is a placeholder in an endpoint's path template — /orders/{id} — that the client fills in to address one instance. Unlike a query parameter it is part of the resource's identity: /orders/42 and /orders/43 are different resources, while /orders?status=open is a view of one.

How it works

The server matches the path against its templates, extracts the segment and validates it: a non-numeric id where a number is expected should be a 400, and a well-formed id with nothing behind it a 404. Values must be percent-encoded — a slash inside a value would otherwise split the path into a different route.

The misconception

That a 404 always means a typo in the URL. For a path parameter it more often means the resource was deleted, never existed, or exists but the caller may not know that — some APIs deliberately answer 404 instead of 403 so as not to confirm an id is real.

Try it here

Every API takes ids in the path. The Voxel Worlds API takes three at once on GET /voxel/v1/worlds/{id}/blocks/{x}/{y}/{z}, and the World Cup API uses a letter rather than a number on GET /worldcup/v1/groups/{letter}/standings.

Sources

Other terms

All glossary terms · Testing techniques · All 39 mock REST APIs

Last updated