---
title: "Capture, replay, and mock with speedctl | Speedscale Docs"
description: "Capture traffic, replay cloud snapshots, and create local mocks with speedctl. For a new proxymock workflow, follow the proxymock CLI quickstart."
canonical: "https://docs.speedscale.com/guides/cli/"
---

[Documentation index](https://docs.speedscale.com/guides/llms.txt) | [Markdown](https://docs.speedscale.com/guides/cli/index.md) | [Canonical page](https://docs.speedscale.com/guides/cli/)

# Capture, replay, and mock with speedctl

This guide uses [speedctl](https://docs.speedscale.com/getting-started/installation/install/cli/) to capture traffic into Speedscale Cloud, replay a cloud snapshot, and create local mocks from that snapshot. Use it when your existing workflow calls for speedctl.

Starting a new record/mock/replay workflow?

Follow the [proxymock CLI quickstart](https://docs.speedscale.com/proxymock/getting-started/quickstart/quickstart-cli/). proxymock supports local, cluster, and cloud workflows; see [choose where a replay runs](https://docs.speedscale.com/proxymock/guides/replay-paths/). For the role of each CLI, see [Command-line tools](https://docs.speedscale.com/getting-started/command-line-tools/).

<a id="prerequisites"></a>

## Prerequisites

*   [speedctl](https://docs.speedscale.com/reference/glossary/#speedctl) installed
*   an existing [snapshot](https://docs.speedscale.com/reference/glossary/#snapshot)
*   an understanding of [Speedscale TLS certificate trust](https://docs.speedscale.com/getting-started/installation/sidecar/tls/#trusting-tls-certificates)

<a id="capture-traffic"></a>

## Capture Traffic

This section is for existing `speedctl capture` integrations that send local traffic to Speedscale Cloud. For a new local recording, use [proxymock record](https://docs.speedscale.com/proxymock/getting-started/quickstart/quickstart-cli/#recording). To use a snapshot you already have, skip to [Run a Replay](https://docs.speedscale.com/guides/cli/#run-a-replay).

caution

`speedctl capture` is not natively supported on Windows. Use [WSL](https://learn.microsoft.com/en-us/windows/wsl/) to get capture support.

In order to capture traffic from your application all inbound and outbound [traffic](https://docs.speedscale.com/reference/glossary/#traffic) will need to be routed through the Speedscale [proxy](https://docs.speedscale.com/reference/glossary/#proxy).

The traffic flow looks like this:

The curl HTTP client is used to make a request directly to the Speedscale proxy which forwards that request to your app, capturing the inbound request. Your app handles the inbound request and makes a database query to Postgres. The outbound query is routed through the Speedscale proxy where the data is captured, and since the responses follow the same path in reverse they are captured as well.

We will need 3 terminal windows for this example.

<a id="terminal-1"></a>

#### Terminal 1

Run `speedctl capture` with the name of your application and the port it is serving on, `9000` in this example. This starts the Speedscale proxy.

```text
speedctl capture a_name_for_my_app 9000
```

<a id="terminal-2"></a>

#### Terminal 2

Set proxy variables to redirect outbound traffic to the Speedscale proxy and start your server.

```text
export http_proxy=http://127.0.0.1:4140
export https_proxy=http://127.0.0.1:4140
./my_app
```

<a id="terminal-3"></a>

#### Terminal 3

Make requests to your app, targeting the proxy instead of your server directly.

```text
curl http://127.0.0.1:4143/foo/bar
```

After about a minute your application should show up in the services list at [https://app.speedscale.com](https://app.speedscale.com/).

<a id="run-a-replay"></a>

## Run a Replay

This section is for existing `speedctl replay` workflows using a cloud snapshot. For a new cloud-to-laptop workflow with proxymock, follow [Replay a Speedscale Cloud Snapshot Locally](https://docs.speedscale.com/proxymock/guides/cloud-snapshot-local/).

Once you have captured traffic you can [create a snapshot](https://docs.speedscale.com/guides/creating-a-snapshot/) and replay it against your app.

![The snapshot supplies recorded data to the generator and responder; runtime requests travel from generator to application to responder, with responses returning separately](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDQwIiBoZWlnaHQ9IjQ3MCIgdmlld0JveD0iMCAwIDEwNDAgNDcwIiByb2xlPSJpbWciIGFyaWEtbGFiZWxsZWRieT0idGl0bGUgZGVzYyI+PHRpdGxlIGlkPSJ0aXRsZSI+QSBzbmFwc2hvdCBzdXBwbGllcyB0aGUgZ2VuZXJhdG9yIGFuZCByZXNwb25kZXI8L3RpdGxlPjxkZXNjIGlkPSJkZXNjIj5UaGUgc25hcHNob3QgaXMgYSBkYXRhc3RvcmUgY29udGFpbmluZyByZWNvcmRlZCByZXF1ZXN0IGFuZCByZXNwb25zZSBkYXRhLiBEYXNoZWQgc3VwcGx5IGx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cGVuZGVuY3kgY2FsbHM8L3RleHQ+PHBhdGggZD0iTTQxOSAzNTlIMjY1IiBzdHJva2U9IiMyYjY1NzkiIHN0cm9rZS13aWR0aD0iMS41IiBmaWxsPSJub25lIiBtYXJrZXItZW5kPSJ1cmwoI2Fycm93KSIvPjx0ZXh0IHg9IjM0Mi4wIiB5PSIzNzkiIGZvbnQtc2l6ZT0iMTIiIGZvbnQtd2VpZ2h0PSI0MDAiIGZpbGw9IiM0MDY4N2MiIHRleHQtYW5jaG9yPSJtaWRkbGUiPlJlc3BvbnNlczwvdGV4dD48cGF0aCBkPSJNNzcxIDM1OUg2MTciIHN0cm9rZT0iIzJiNjU3OSIgc3Ryb2tlLXdpZHRoPSIxLjUiIGZpbGw9Im5vbmUiIG1hcmtlci1lbmQ9InVybCgjYXJyb3cpIi8+PHRleHQgeD0iNjk0LjAiIHk9IjM3OSIgZm9udC1zaXplPSIxMiIgZm9udC13ZWlnaHQ9IjQwMCIgZmlsbD0iIzQwNjg3YyIgdGV4dC1hbmNob3I9Im1pZGRsZSI+TW9ja2VkIHJlc3BvbnNlczwvdGV4dD48dGV4dCB4PSI0MiIgeT0iNDQ2IiBmb250LXNpemU9IjEzIiBmb250LXdlaWdodD0iNDAwIiBmaWxsPSIjOGI3MDNmIiB0ZXh0LWFuY2hvcj0ic3RhcnQiPkRhc2hlZDogc25hcHNob3QgZGF0YSBzdXBwbHk8L3RleHQ+PHRleHQgeD0iMzk3IiB5PSI0NDYiIGZvbnQtc2l6ZT0iMTMiIGZvbnQtd2VpZ2h0PSI0MDAiIGZpbGw9IiM0MDY4N2MiIHRleHQtYW5jaG9yPSJzdGFydCI+U29saWQ6IHJlcXVlc3QgLyByZXNwb25zZSB0cmFmZmljPC90ZXh0PjwvZz48L3N2Zz4=)

[Open diagram full size](https://docs.speedscale.com/img/diagrams/replay-snapshot-datastore.svg)

The captured traffic is loaded into Speedscale components before the replay starts. The [generator](https://docs.speedscale.com/reference/glossary/#generator) makes requests to your app and the [responder](https://docs.speedscale.com/reference/glossary/#responder) mocks external resources.

We will need 2 terminal windows for this example.

<a id="terminal-1-1"></a>

#### Terminal 1

Set proxy variables to redirect outbound traffic to the Speedscale responder and start your server.

```text
export http_proxy=http://localhost:4140
export https_proxy=http://localhost:4140
./my_app
```

This ensures your application's outbound requests are routed to the responder.

<a id="terminal-2-1"></a>

#### Terminal 2

Run `speedctl replay` with the snapshot ID. The snapshot ID can be copied by clicking the three dots in the top right corner of the screen when viewing a snapshot. Snapshots are listed on the [snapshots page](https://app.speedscale.com/snapshots).

The example here runs a replay with the traffic from the snapshot with ID `310457d7-b17a-4802-897c-ac98004dab21`, using the test config `standard-passthrough`, and targeting a local application serving traffic on port 8081.

```text
speedctl replay 310457d7-b17a-4802-897c-ac98004dab21 \
  --test-config-id=standard-passthrough \
  --test-against='http://localhost:8081'
```

The `--test-against` flag sets the destination for replay requests. See [Replay with speedctl](https://docs.speedscale.com/guides/replay/via-speedctl/) for routing individual services to different targets.

This command will run both the generator and the responder in the same terminal window and your app should receive all requests from the snapshot.

note

With `--daemon` flag, You can run generator and responder as a background process.

<a id="create-local-mocks"></a>

## Create Local Mocks

This section continues an existing speedctl workflow with `--mode=mocks-only`. For proxymock dependency mocks, use the [cloud snapshot local replay guide](https://docs.speedscale.com/proxymock/guides/cloud-snapshot-local/#mock) or the [proxymock CLI quickstart](https://docs.speedscale.com/proxymock/getting-started/quickstart/quickstart-cli/#run-mocks).

Local mocks are just another replay with no generator.

We will need 2 terminal windows for this example.

<a id="terminal-1-2"></a>

#### Terminal 1

Just as with the replay, set proxy variables to redirect outbound traffic to the Speedscale responder and start your server.

```text
export http_proxy=http://localhost:4140
export https_proxy=http://localhost:4140
./my_app
```

This ensures your application's outbound requests are routed to the responder.

<a id="terminal-2-2"></a>

#### Terminal 2

Run `speedctl replay`, but this time with the flag `--mode=mocks-only`. This will only run the responder, allowing your app to make outbound requests that respond with data from the snapshot.

Now you can test your application with predictable data. Outbound requests will be routed to the responder and your app will receive mocked responses from snapshot traffic.
