# Editing with Snapshots

## Prerequisites

1. [Snapshot requests](https://docs.stoobly.com/guides/how-to-mock-apis/how-to-snapshot-requests)
2. (Optional) Use a version tool such as Git to backup changes

## Updating Requests by Editing Snapshots

{% stepper %}
{% step %}
**Find request snapshots that match a pattern**

Run the following CLI command:

```bash
stoobly-agent snapshot list --search <PATTERN> --select snapshot --select uuid
```

For example:

```bash
$ stoobly-agent snapshot list --search /api --select snapshot --select uuid
snapshot                                                             uuid
.stoobly/snapshots/requests/19/19cfd765-80bc-4a2c-ad36-c59e7dbb9c92  cd99c578-3a97-11f0-98ef-51122b0b22b6
```

{% endstep %}

{% step %}
**Edit request snapshots**

For each file found, make the desired change to the request snapshot.

In the example from step 1, the request snapshot is stored in `.stoobly/snapshots/requests/19/19cfd765-80bc-4a2c-ad36-c59e7dbb9c92` .
{% endstep %}

{% step %}
**Create new snapshots for each updated request**

Run the following CLI command:

```bash
stoobly-agent snapshot update <SNAPSHOT-UUID>
```

In the example from step 1, the snapshot uuid is `cd99c578-3a97-11f0-98ef-51122b0b22b6`.
{% endstep %}

{% step %}
**Apply the snapshots**

Run the following CLI command:

```
stoobly-agent snapshot apply
```

{% endstep %}
{% endstepper %}
