# Rewrite Rules

{% hint style="info" %}
**Configures:**

* How to modify parts of a request?
  {% endhint %}

Rewrite rules enable modification of any part of a request. Rules are applied if a request URL matches the provided regex **pattern.** If there are no rewrite rules or a request URL does not match any of the rule patterns, then there will be no modifications to the intercepted request.

## Rule Configuration

<figure><img src="/files/1O0DCb24qcGSrGswaloW" alt=""><figcaption><p>Figure 1. Rewrite rule</p></figcaption></figure>

### Method

HTTP verb(s) the rule applies to such as GET, POST, DELETE, etc.

### Pattern

Pattern to match with the request URL to apply the rule to. This supports regular expressions.

### Parameters

Which components of the request to match on, such as header, body, and query param.

### Name

Name of the component

e.g. for the header `Authorization: Token` , the name is `Authorization`

### Value

Value of the component

e.g. for the header `Authorization: Token` , the value is `Token`

### Modes Applied To

Which agent mode to apply the filter rule to such as mock, record and/or replay

## Example

For example, say you want to record requests to endpoints that require valid OAuth tokens. Let's say that endpoint is `GET https://internal.company.com/v1/users` . Then you can create a rewrite rule with the following values:

* Method - `GET`
* Pattern - `https://internal.company.com/v1/users`
* Parameter Type - `Header`
* Parameter Name - `Authorization`
* Value - `REDACTED TOKEN`
* Modes Applied To - `Record`

When recording, this will configure the agent to rewrite the `Authorization` header's value with `REDACTED TOKEN`. Similarly, when replaying a request, we can also create a rule set this same header with a valid token. For advance use cases, see:

{% content-ref url="/pages/L80ROjPjA3paJPSgdFzA" %}
[How to Customize Recordings](/guides/how-to-record-requests/how-to-customize-recordings.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stoobly.com/core-concepts/agent/proxy-settings/rewrite-rules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
