> 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-mock-apis/how-to-snapshot-requests.md).

# How to Snapshot Requests

## Background

{% content-ref url="/pages/WFKkQFPE0l9Zauwmdgd6" %}
[Snapshots](/core-concepts/mock-api/snapshots.md)
{% endcontent-ref %}

## Prerequisites

1. [Install the agent](/getting-started/install-and-run.md)
2. [Create a new Stoobly context](/guides/how-to-record-requests/how-to-create-contexts.md)
3. [Record requests](/guides/how-to-record-requests.md)

## Snapshotting Requests

### Command

```bash
stoobly-agent request snapshot "<REQUEST-KEY>"
```

The following page provides details on how to obtain the request's key:

{% content-ref url="/pages/-MaqwgidRyGQ24EvuqhN" %}
[Request](/core-concepts/mock-api/requests.md)
{% endcontent-ref %}

For our example the request key will be `p0.i4a449553b0744782809fe52d8358da78`

To add the corresponding request to a snapshot, run the following command with the key like this:

```
$ stoobly-agent request snapshot --action PUT p0.i4a449553b0744782809fe52d8358da78
```

Afterwards in your data directory you'll see a new `snapshots` directory has been created. Here is an example of what that directory looks like:

```
/home/user/.stoobly/snapshots
├── log
└── requests
    └── 4a
        └── 4a449553-b074-4782-809f-e52d8358da78
```

### Options

```bash
$ stoobly-agent request snapshot --help
Usage: stoobly-agent request snapshot [OPTIONS] REQUEST_KEY

  Snapshot a request

Options:
  --action [DELETE|PUT]  Sets snapshot action.
  -h, --help             Show this message and exit.
```

## Snapshotting Scenarios

### Command

```
stoobly-agent scenario snapshot "<SCENARIO-KEY>"
```

### Options

```bash
$ stoobly-agent scenario snapshot --help
Usage: stoobly-agent scenario snapshot [OPTIONS] "<SCENARIO_KEY>"

  Snapshot a scenario

Options:
  --action [DELETE|PUT]  Sets snapshot action.
  -h, --help             Show this message and exit.
```
