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

# How to Modify HTML Document using Modify API Response Rule

Requestly Interceptor's **Modify API Response** rule lets you **directly modify the response of top-level HTML documents**. This feature is **only available for desktop app** but you can use file server and redirect rule as a workaround for most use cases.

> [!NOTE]
>
> [**Click here to download**](https://requestly.com/downloads/) the Desktop App for your OS.

**1. Create a Response Rule**

Navigate to the HTTP Rules section in the Requestly Interceptor app. Click `+ New Rule` and choose the `Modify API Response` option.

![](https://mintcdn.com/interceptor/fhZRboFseopn8ocm/images/modify-html-document-using-modify-api-response-rule/10acf5f2-7052-4fe8-b9f4-13c01e026082.png?fit=max\&auto=format\&n=fhZRboFseopn8ocm\&q=85\&s=6c90cb1ec8fb63ab7da2c2b903894a71)

**2. Name and Describe Your Rule**

Provide a **descriptive name** for the rule to keep your setup organized. Optionally, add a **brief description** explaining its purpose for easier identification later.

**3. Select Resource Type**

In the Resource Type choose HTML/ JS/ CSS

![](https://mintcdn.com/interceptor/fhZRboFseopn8ocm/images/modify-html-document-using-modify-api-response-rule/fed9b55a-7ad9-461a-8eca-2e4d8e3ec51e.png?fit=max\&auto=format\&n=fhZRboFseopn8ocm\&q=85\&s=25329fe905bf650f23b7579a96c9121d)

**4. Define Matching Criteria**

Define the criteria for the rule to be applied, such as **URL**, **Host**, or **Path**. Choose from **Regex**, **Contains**, **Wildcard**, or **Equals**, or use [**Advance Filters**](https://interceptor-docs.requestly.com/http-rules/advanced-usage/advance-filters.md) for more precise conditions.

For more detailed guidance, refer to [**Source Conditions Guide**](https://interceptor-docs.requestly.com/http-rules/advanced-usage/source-conditions.md).

**5. Change Response Status Code**

Modify the status code of the response using the dropdown menu. Choose from:

* `2XX` for successful responses

* `4XX` for client errors

* `5XX` for server errors

If left empty, the original status code remains unchanged.

![](https://mintcdn.com/interceptor/fhZRboFseopn8ocm/images/modify-html-document-using-modify-api-response-rule/a500b630-4b38-4d3d-bae7-45fb3dd254b6.png?fit=max\&auto=format\&n=fhZRboFseopn8ocm\&q=85\&s=7b0e761c270c019b9608df0dca13fce7)

**6. Modify Response Data**

Choose one of the following methods to modify the response data:

* **Static Response Modification**: Input a static value as the response body.

* **Dynamic** **Modification Script (JavaScript)**: Use JavaScript to modify responses dynamically. The script provides access to parameters like:

  * `method`: HTTP Method (GET, POST, etc.)

  * `url`: Full URL of the request

  * `response`: Original response body (string)

  * `responseType`: Content type of the original response

  * `requestHeaders`: Headers sent with the request

  * `responseJSON`: Original response parsed as a JSON object

**7. Save and Activate the Rule**

Click **Save** to store the rule and toggle it **ON**. This will apply the rule to the defined source conditions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.