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

# Web Request

> Listen for and intercept HTTP requests made by the browser at various lifecycle stages

The Web Request command (Command Type: 18) hooks into the browser's web request lifecycle and intercepts HTTP requests at specified stages (before sending headers, on response, on error, etc.).

## Command Type

**Command Type ID:** 18

## Parameters

| Parameter    | Type                     | Description                                            | Required |
| ------------ | ------------------------ | ------------------------------------------------------ | -------- |
| **listener** | string                   | Web request lifecycle event to listen for              | Yes      |
| **name**     | string                   | Unique identifier for this listener                    | Yes      |
| **timeout**  | number                   | Timeout in milliseconds                                | Yes      |
| **filters**  | WebRequest.RequestFilter | Criteria to filter which requests trigger the listener | No       |
| **options**  | WebRequestOptions        | Additional options for request handling                | No       |

### Listener Values

| Value                   | Description                                      |
| ----------------------- | ------------------------------------------------ |
| `"onBeforeRequest"`     | Triggered before a request is made               |
| `"onBeforeSendHeaders"` | Triggered before headers are sent                |
| `"onSendHeaders"`       | Triggered after headers are sent                 |
| `"onHeadersReceived"`   | Triggered after headers are received             |
| `"onAuthRequired"`      | Triggered when server requires authentication    |
| `"onBeforeRedirect"`    | Triggered before a redirect                      |
| `"onCompleted"`         | Triggered when request completes successfully    |
| `"onErrorOccurred"`     | Triggered when an error occurs                   |
| `"onResponseStarted"`   | Triggered when the response body starts arriving |

### WebRequest.RequestFilter

| Field         | Type            | Description             | Required |
| ------------- | --------------- | ----------------------- | -------- |
| **urls**      | Array of string | URL patterns to match   | Yes      |
| **types**     | Array of string | Resource types to match | No       |
| **tabId**     | number          | Match specific tab      | No       |
| **incognito** | boolean         | Match incognito state   | No       |

## Usage Examples

### Capture API Responses

```json theme={null}
{
  "command": "web-request",
  "params": {
    "listener": "onCompleted",
    "name": "apiListener",
    "timeout": 30000,
    "filters": {
      "urls": ["*://api.example.com/*"],
      "types": ["xmlhttprequest"]
    }
  }
}
```

### Intercept Before Headers Are Sent

```json theme={null}
{
  "command": "web-request",
  "params": {
    "listener": "onBeforeSendHeaders",
    "name": "headerInterceptor",
    "timeout": 15000,
    "filters": { "urls": ["*://example.com/*"] }
  }
}
```

## Related Commands

* [Override Headers](/stream/commands/browser/override-headers) - Override request headers
* [Fetch Web Request](/stream/commands/browser/fetch-web-request) - Make fetch requests
* [Capture HAR File](/stream/commands/browser/capture-har-file) - Capture all network activity
