Homeglossary

Path Parameters

Path parameters are URL components that identify a specific resource or route within a web application or API. They are variable values placed in the URL path, such as /users/42, where 42 identifies one user. Unlike query parameters, they usually describe which resource the server should retrieve or act on.

Build routes with clear resource paths using Emergent.

What are path parameters in an API?

Path parameters are variable parts of a URL that identify a specific resource or route in a web application or API. In /products/123, 123 selects one product. They are also called path variables or route parameters.

How path parameters work in a URL path

A server matches the incoming URL against a route template.

  1. Define a template, such as /products/{id} or /products/:id.
  2. Receive a request such as /products/123.
  3. Match 123 to the variable segment.
  4. Validate and convert it, for example to an integer or UUID.
  5. Return the resource, or an appropriate error.

Path parameters vs. query parameters

Use the path for identity. Use query parameters for optional ways to refine a request.

Path parameterQuery parameter
Inside the URL pathAfter ?
/products/123/products?sort=price
Usually required for route matchingUsually optional for filters, search, sorting, or pagination
Changes the resource route and cache keyChanges request options and often the cache key

When to use path parameters

Choose them when the value is part of the resource’s address.

  • Unique IDs, such as /orders/81.
  • Nested resources, such as /users/42/orders.
  • Stable readable slugs, such as /articles/path-parameters.
  • Action routes only when an HTTP method cannot express the action clearly.
  • Keep optional URL parameters, such as page or filter choices, in the query string.

Practical limits and common mistakes

Small routing decisions prevent confusing API behavior.

  • Register /users/me before /users/{id} when the framework uses route order.
  • Do not make a path segment optional. Create a separate route or use a query parameter.
  • URL-encode reserved characters and validate every value.
  • Return 400 for an invalid format and 404 when a valid identifier has no matching resource.
  • Avoid exposing secrets or inconsistent, overly deep nesting.

Path parameters in app development with Emergent

Clear route requirements help Emergent generate consistent frontend links, backend endpoints, validation, and tests for full-stack apps. Explore the Learn hub and broader glossary to plan routes with confidence. Build routes with clear resource paths using Emergent.

Frequently Asked Questions

Your Questions, Answered

This will automatically populate, don't change

Don't change this element unless you know what you are doing

What are path parameters in a REST API?

They are variable URL segments that identify a resource, such as /customers/42.

When should I use path parameters vs. query parameters?

Use path parameters for the resource being addressed. Use query parameters for optional filters, sorting, search, and pagination.

How do I pass a path parameter in a URL?

Replace the route placeholder with a value, such as changing /products/{id} to /products/123.

How do I send path parameters in Postman?

Enter the completed URL in the request field, or define a route variable and provide its value in Postman’s path variables editor.

What is the difference between a path parameter and a query parameter?

A path parameter is part of the route and usually identifies a resource. A query parameter follows ? and usually modifies or filters the request.

Start Building
on Emergent today
Start Building