# 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.
```


---

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