> For the complete documentation index, see [llms.txt](https://akhilgangula.gitbook.io/mock-json-response/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://akhilgangula.gitbook.io/mock-json-response/request.md).

# Request

Request matching

Mock JSON Response supports matching of requests to stub using the following attributes

1. URL
2. HTTP Method
3. Headers

Here is an example:

```javascript
{
    method: "GET",
    urlPath: "/mock/list",
    headers: {
        "x-route": {
            equalTo: "items-list"
        }
    }
}
```

{% hint style="info" %}
&#x20;method and urlPath are mandatory for request matching.&#x20;
{% endhint %}

### URL Path

This is the path of the requested URL. This field will accept both the string and regex as value.&#x20;

```javascript
urlPath: "/list/([0-9]+)/items"
```

The above URL path will be matched with <http://localhost:3000/list/shopping/items>

### Method

Request method such as GET, POST, PUT, PATCH, DELETE and others will be matched with the help of this attribute.

### Headers

Headers is an object that holds the header, helper and the value of the header to be matched together. Helpers supported in Mock JSON Response are "equalTo", "matches", "contains". As the name suggests these helper match when URL is an exact match, when the regex is a match and contains in the incoming request.

```javascript
{
    method: "GET",
    urlPath: "/mock/list",
    headers: {
        "x-route": {
            equalTo: "items-list"
        }
    }
}
```

Above example matches to a request: GET <http://localhost:3000/mock/list> with x-route: "items-list" as headers.

{% hint style="info" %}
If a request has multiple matches, a warning message, with the possible stub name will be received.&#x20;
{% endhint %}

Other possible fields of the request will be explained in later sections.
