> ## Documentation Index
> Fetch the complete documentation index at: https://docs.requestly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Routes

> Match incoming requests in a Requestly mock server by method and path, capture path parameters, use wildcards, and control route ordering when two routes overlap.

A route is a method and a path that the mock answers on. When a request arrives, the mock walks its routes from top to bottom and picks the first one whose method and path match. That route then decides which response to serve. This page covers how the matching works.

For the basics of creating a mock and serving your first response, see [Mock Server](/api-client/mock-server).

## Method and path

Add a route with the **+** button above the routes list, then set two things in the response pane at the top:

* **Method**: any standard HTTP verb (`GET`, `POST`, `PUT`, `DELETE`, and so on), plus `*` to match any method.
* **Path**: the path the route answers on, relative to the mock's base URL. It supports path parameters (`:param`) and wildcards (`*`), described below.

Use the filter box above the routes list to find a route by path in a long list, and drag a route up or down to change its order.

## Path parameters

A path segment written as `:name` captures whatever appears in that position and exposes it to your response. The captured value is available both in response templates (as `urlParam.name`) and in [matching rules](/api-client/mock-server/rules) via the URL Param target.

For example, a route `GET /users/:id` with this response body:

```json theme={null}
{"userId":"{{request.urlParam.id}}","note":"the :id path param, echoed"}
```

serves the captured id straight back to the caller:

```bash theme={null}
curl https://<id>.mocks.requestly.cloud/users/42
```

```json theme={null}
{"userId":"42","note":"the :id path param, echoed"}
```

A path parameter matches exactly one segment. `GET /users/:id` matches `/users/42` but does not match `/users` on its own, so a bare `/users` request finds no route and returns `404`:

```bash theme={null}
curl -i https://<id>.mocks.requestly.cloud/users
```

```text theme={null}
HTTP/1.1 404 Not Found
```

## Wildcards

A `*` in the path matches any characters, including slashes, and captures them as `urlParam.0`. Pair it with method `*` to answer every HTTP method on that path.

For example, a route with method `*` and path `/static/*` and this body:

```json theme={null}
{"matchedMethod":"{{request.method}}","matchedPath":"{{request.path}}","wildcard":"{{request.urlParam.0}}"}
```

matches many paths and every method:

```bash theme={null}
curl https://<id>.mocks.requestly.cloud/static/css/app.css
```

```json theme={null}
{"matchedMethod":"GET","matchedPath":"/static/css/app.css","wildcard":"css/app.css"}
```

```bash theme={null}
curl -X POST https://<id>.mocks.requestly.cloud/static/js/x.js
```

```json theme={null}
{"matchedMethod":"POST","matchedPath":"/static/js/x.js","wildcard":"js/x.js"}
```

```bash theme={null}
curl -X DELETE https://<id>.mocks.requestly.cloud/static/a/b/c
```

```json theme={null}
{"matchedMethod":"DELETE","matchedPath":"/static/a/b/c","wildcard":"a/b/c"}
```

The `{{request.method}}`, `{{request.path}}`, and `{{request.urlParam.0}}` placeholders above are dynamic values. See [dynamic values](/api-client/mock-server/responses#dynamic-values) for the full list.

## Ordering and shadowing

Matching is first-match-wins by position: when two routes share the same method and path, the one higher in the list intercepts every request and the one below it is never reached.

For example, with two `GET /shadow` routes where the first returns `200 {"served":"first-route-wins"}` and the second returns `500`, the first always wins:

```bash theme={null}
curl https://<id>.mocks.requestly.cloud/shadow
```

```json theme={null}
{"served":"first-route-wins"}
```

The second route's `500` never appears. The editor flags the shadowed route with a strike-through and a warning icon, with the tooltip "Shadowed by an earlier route with the same method and path - this route is never served", so you can spot and fix the conflict. Drag the route you want to win to the top, or change one route's method or path so they no longer collide.

<Tip>
  Ordering also drives the **Fallback** selection mode, where a route that finds no matching response deliberately falls through to the next route that matches the same request. See [selection modes](/api-client/mock-server/responses#selection-modes).
</Tip>
