# Save captured requests

> Turn requests captured by Cloak Proxy into saved API client requests with Save to API Client, keeping headers, body and the response as an example.

Source: https://docs.subcloak.com/cloak-proxy/api-client/capture-to-client/

Any request the proxy captured can become a saved request in the API client. The client copies its method, URL, headers and body, and keeps the response as an example. Use it to reproduce what an app sent, tweak it and send it again, add tests to it, or start a collection for an API you're learning from real traffic.

## Save a request from the traffic list

*[Screenshot: The traffic list with one GET request to api.example.com/v1/users selected, and the inspector below showing its Authorization bearer token and Cookie header. A captured request carries real credentials. They come along when you save it.]*

1. In the main window's [traffic list](https://docs.subcloak.com/cloak-proxy/inspect/traffic-list/), select the request. Select several to save them together.
2. Right-click and choose **Save to API Client**. With several selected, it reads **Save N Requests to API Client**.
3. The API client opens with the last saved request in a tab, inside a collection called **Captured Requests**.

The **Captured Requests** collection is created the first time and reused after that. Each request is added at its top level. Move them into other collections or folders by dragging them in the sidebar; see [Collections and requests](https://docs.subcloak.com/cloak-proxy/api-client/collections-and-requests/#organize-the-sidebar).

**Save to API Client** isn't available for CONNECT tunnels the proxy didn't decrypt, since there's no request inside to copy. Turn on [SSL Proxying](https://docs.subcloak.com/cloak-proxy/capture/ssl-proxying/) for the host and capture it again.

You can also save the selected request from global search (<kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>A</kbd>): search for **Save Selected Request to API Client**.

## What gets copied

| Part | In the saved request |
|---|---|
| Name | The method and path, such as `GET /v1/users`. |
| Method and URL | As captured, including the query string. |
| Query parameters | Listed on the **Params** tab. |
| Headers | Every request header except `Host`, `Content-Length`, `Connection`, `Proxy-Connection` and `Accept-Encoding`, which the client sets itself. |
| Form body (`application/x-www-form-urlencoded`) | An **x-www-form-urlencoded** body with one row per field. The captured `Content-Type` header is dropped, since the body type sets it. |
| Other text bodies | A **Raw** body. JSON is pretty-printed. The language is **JSON** or **XML** from the `Content-Type`, otherwise **TEXT**. Compressed bodies are decoded first. |
| Response | Saved as an example named after the status, such as "200 OK", with its headers (minus `Content-Length`, `Content-Encoding`, `Transfer-Encoding`, `Connection` and `Date`) and decoded body. |

Binary request bodies, such as images or Protobuf, aren't copied. Auth isn't detected: an `Authorization` header stays a header, and the request's **Authorization** tab is set to **Inherit auth from parent**.

The saved request has its examples ready for a [mock server](https://docs.subcloak.com/cloak-proxy/api-client/run/mock-servers/) and [exported docs](https://docs.subcloak.com/cloak-proxy/api-client/examples-and-docs/).

## Clean it up

A captured request is a snapshot of one call. Before you reuse or share it:

1. Replace the host with a variable. Change `https://api.example.com/v1/users` to `{{baseUrl}}/v1/users` and set `baseUrl` in an [environment](https://docs.subcloak.com/cloak-proxy/api-client/variables-and-environments/#environments).
2. Move credentials out of headers. Delete the captured `Authorization` header and set up auth on the **Authorization** tab, or on the collection, with a value from a secret variable or `{{vault:name}}`.
3. Delete the `Cookie` header unless the API needs it. The client keeps its own [cookie jar](https://docs.subcloak.com/cloak-proxy/api-client/collections-and-requests/#read-the-response) from the responses it gets.
4. Remove headers that only made sense for the original app, such as tracing IDs.
5. Rename the request to say what it does.

> **Captured requests contain live credentials:**
> Saved requests are plain JSON files in the [workspace folder](https://docs.subcloak.com/cloak-proxy/api-client/workspace-and-git/). A captured request's tokens, cookies and API keys are in that file until you remove them, and are committed if you use Git, exported to Postman, and shown in exported docs. Clean them up first. The Vault view's [hardcoded secrets check](https://docs.subcloak.com/cloak-proxy/api-client/variables-and-environments/#find-hardcoded-secrets) lists the ones it recognizes.
>
> Only save and replay traffic from your own apps and accounts, or with permission.

## Other ways to bring traffic in

| Method | Result |
|---|---|
| Export a session as HAR, then [import](https://docs.subcloak.com/cloak-proxy/api-client/import-and-export/) it into the client | A collection named after the file, with one folder per host. Responses become examples. |
| **Copy as cURL** on a captured request (right-click it in the traffic list), then paste into a request's URL field in the client (<kbd>⌘</kbd> <kbd>T</kbd> opens a new one) | The method, URL, headers and body fill in that request. See [Copy as code](https://docs.subcloak.com/cloak-proxy/inspect/copy-as-code/). |
| The MCP tool `save_captured_request` | An AI assistant saves a captured request into a collection (default **Captured Requests**). See [MCP tools reference](https://docs.subcloak.com/cloak-proxy/automation/mcp-tools-reference/). |

To change a captured request and send it again without saving it in the client, use **Edit and Repeat…** in the proxy. See [Repeat and compose](https://docs.subcloak.com/cloak-proxy/tools/repeat-and-compose/).

## Related

  - [Collections and requests](https://docs.subcloak.com/cloak-proxy/api-client/collections-and-requests/): Edit and send the saved request.
  - [Repeat and compose](https://docs.subcloak.com/cloak-proxy/tools/repeat-and-compose/): Resend captured requests from the proxy.
  - [Turn traffic into API docs](https://docs.subcloak.com/cloak-proxy/guides/turn-traffic-into-api-docs/): From captured calls to a documented collection.
  - [Make tests from traffic](https://docs.subcloak.com/cloak-proxy/testing/make-tests/): Save captured requests as a test suite instead.
