# Intercept XHR Request

Source: https://docs.scrappey.com/docs/intercept-xhr

> Use `interceptFetchRequest` to inspect permitted network responses generated by an authorized browser session by capturing specific `fetch()` or XHR requests during a page load.

## Command

`"interceptFetchRequest"` — monitor network activity and return specific XHR/fetch responses. URL matching uses `.includes()`; if more than one request matches the string, all are returned as an array.

## Parameters

| Parameter | Type | Required | Description |
| ----------------------- | ------ | -------- | ---------------------------------------------------------------------- |
| `interceptFetchRequest` | array | Yes | List of strings to match against outgoing request URLs |
| `url` | string | Yes | URL to be loaded and monitored |
| `browserActions` | array | No | [Browser actions](/docs/browser-actions) (e.g., verification flow handling) to perform during request |

## Example

```bash
curl -X POST "https://publisher.scrappey.com/api/v1?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cmd": "request.get",
    "url": "https://example.com/dashboard?input=example.com",
    "interceptFetchRequest": [
      "https://example.com/api/v4/overview"
    ],
    "browserActions": [
      {
        "type": "solve_captcha",
        "captcha": "custom"
      }
    ]
  }'
```

You will receive an array of JSON responses from all fetch/XHR requests that matched the string(s) provided.

## Notes

Great for:

- Sites that dynamically load content via JavaScript
- Skipping complex DOM parsing by reading documented or permitted application endpoints
- Working with documented or permitted application endpoints

Use `interceptFetchRequest` to inspect permitted network responses generated by authorized browser sessions. Pair it with [`execute_js`](/docs/execute-javascript) to post-process the captured data.
