---
title: "Variables | Speedscale Docs"
description: "Explore how to use variables in Speedscale for persistent data storage across requests, including key-value pairs and transform functions for enhanced API testing."
canonical: "https://docs.speedscale.com/guides/transformation/variables/"
---

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

# Variables

Variables allow you to store a piece of data persistently across requests. Variables are stored using a key and value and can be loaded at any time.

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

## Variables

Transform variables provide a way to share data between requests. For example, you may want to store an ID from the response body of one request and use it in the URL of another.

Variables can be thought of as a map of key=value pairs. Once set, they can be retrieved and modified using a set of transforms including:

*   **[var\_store](https://docs.speedscale.com/guides/transformation/transforms/variable_store/)** - Assign a new value to a variable
*   **[var\_load](https://docs.speedscale.com/guides/transformation/transforms/variable_load/)** - Replace current value with the value of a variable

This is the simplest way to interact with the variable storage system, but not necessarily the most powerful. Keep in mind that [smart replace](https://docs.speedscale.com/guides/transformation/transforms/smart_replace/) transforms are independent of the variable cache and changes made in one will not be reflected in the other. Variables are for custom use cases. Smart replace is for more automated use cases and is a better starting place for most users.

<a id="scope"></a>

### Scope

Variables for Tests on the Prepare tab are scoped to the current [vUser](https://docs.speedscale.com/reference/glossary/#vuser) or "thread" within the load generator, which runs through the snapshot traffic at most 1 time. Each vUser has a separate variable cache, just like HTTP clients talking to the same server don't share information.

![variable\_from\_rrpair](https://docs.speedscale.com/assets/images/variable_from_rrpair-61afcab263b42d960d01d093ce6b4e3d.png)

If you need more of a "global replace" functionality you should use variables from **Test variables** or **Mock variables** on the Prepare tab. Transforms created here are run once at the start of each vUser.

![variable\_from\_variables](https://docs.speedscale.com/assets/images/variable_from_variables_tab-7fbc6c2d614315f631c939959cc58340.png)

<a id="embedded"></a>

### Embedded

Embed a variable in transform configuration with `${{variable1}}`. For example, a [Constant](https://docs.speedscale.com/guides/transformation/transforms/constant/) value of `new_value=${{variable1}}` substitutes the stored value while keeping the `new_value=` prefix.

![Constant step with an embedded variable in the new field](https://docs.speedscale.com/assets/images/constant-embedded-d989fa1f2fef9f533eb8d06d6b435b8d.jpg)

[Open screenshot full size](https://docs.speedscale.com/assets/images/constant-embedded-d989fa1f2fef9f533eb8d06d6b435b8d.jpg)

The same syntax works in configuration fields for [JWT Resign](https://docs.speedscale.com/guides/transformation/transforms/jwt_resign/). Keep the placeholder in the field whose value should be supplied from a variable.

These two views of the JWT Resign form show a secret reference in `secretPath` and a variable in `sub`. The values are configuration placeholders.

![JWT Resign secretPath with a documentation secret reference](https://docs.speedscale.com/assets/images/jwt-secret-reference-535c5caf579f520adfbe939cf052f287.jpg)

[Open screenshot full size](https://docs.speedscale.com/assets/images/jwt-secret-reference-535c5caf579f520adfbe939cf052f287.jpg)

![JWT Resign sub field with the new\_sub variable](https://docs.speedscale.com/assets/images/jwt-embedded-subject-3cbca087e96541783b389d3f9dba3f31.jpg)

[Open screenshot full size](https://docs.speedscale.com/assets/images/jwt-embedded-subject-3cbca087e96541783b389d3f9dba3f31.jpg)

Embedded values also support environment variables, random strings, files, [user data](https://docs.speedscale.com/reference/glossary/#user-data), dataframe lookups and secrets. See [Embedded Syntax](https://docs.speedscale.com/guides/transformation/embedded-syntax/) for the complete reference.
