> For the complete documentation index, see [llms.txt](https://docs.stoobly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stoobly.com/guides/how-to-update-requests/how-to-update-scenarios/updating-with-overwrite.md).

# Updating with Overwrite

## Background

{% content-ref url="/pages/WGDfUf8LR718Ltv79uSX" %}
[How to Update Scenarios](/guides/how-to-update-requests/how-to-update-scenarios.md)
{% endcontent-ref %}

## Overwriting

The following will overwrite the scenario with newly recorded requests and their respective responses.

{% tabs %}
{% tab title="CLI" %}
**Steps**

1. Select the scenario you want to overwrite. To select the scenario, set the [scenario key](/core-concepts/mock-api/scenarios.md#scenario-key):

```bash
stoobly-agent setting scenario "<SCENARIO_KEY>"
```

2. Set the Agent to **record** mode with **overwrite** policy.

```bash
stoobly-agent intercept set --mode record --policy overwrite
```

3. Enable request interception with the Agent.

```bash
stoobly-agent intercept enable
```

4. Replay the scenario either by trigging requests from the application or rerunning a test to verify that the overwrite behaves as expected.
5. (Optional) Persist the changes with a snapshot to commit the updates to version control:

```bash
stoobly-agent scenario snapshot "<SCENARIO_KEY>"
```

This allows you to:

* Version control your updated scenario via Git
* Share the updates with your team
* Revert to this snapshot if needed later
  {% endtab %}

{% tab title="UI" %}
In the **Proxy Settings** go to the **Data** section.

1. Set a scenario
2. For the **Record Policy**, choose **overwrite**. Then click the **Update** button at the bottom
3. Finally set the **Proxy Mode** at the top left to **Record** and click the **Run** button to start intercepting requests

Below is a screenshot showing what the UI configuration will look like:

<figure><img src="/files/YCGLpelN4TEf0kJdQUCe" alt=""><figcaption></figcaption></figure>

4. (Optional) Persist the changes with a snapshot if you want the updates committed to version control:

```bash
stoobly-agent scenario snapshot "<SCENARIO_KEY>"
```

This allows you to:

* Version control your updated scenario via Git
* Share the updates with your team
* Revert to this snapshot if needed later
  {% endtab %}
  {% endtabs %}

## Cleanup

After overwriting your scenario successfully, you can disable intercepting requests with the Agent with the following command:

```bash
stoobly-agent intercept disable
```

You can also update your scenario key back to what it was before or you can clear it out so the Agent will not use any scenario. To clear the active scenario, run the following command:

```bash
stoobly-agent setting scenario clear
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.stoobly.com/guides/how-to-update-requests/how-to-update-scenarios/updating-with-overwrite.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
