← Back to Overview

TESTING

Set Variables

Extract values from API responses and save them as environment variables — no code needed. Perfect for request chaining and dynamic workflows.

Overview

Set Variables are GUI rules that extract values from the response and save them as environment variables. They require no scripting — just configure the extraction source, property path, and target variable name.

Found in the Tests tab, below the assertion rules (GUI Test Rules).

Each rule has four fields:

source property variableName enabled
Extracted values are saved to the active environment
Available immediately in subsequent requests as {{variableName}}
No JavaScript required — purely GUI-driven configuration

Extraction Sources

Four extraction sources are available, each targeting a different part of the response:

$

jsonpath

Extract using a JSONPath expression. The property field is the JSONPath (e.g., $.data.token, $.items[0].id).

header

Extract a response header value. The property field is the header name (e.g., X-Request-Id, Location).

body

Saves the full response body as the variable value. No property needed — the entire body text is captured.

.*

regex

Extract using a regex pattern with a capture group. The property field is the regex — the first capture group is saved (e.g., "token":"([^"]+)").

Adding Rules

To add a Set Variable rule:

1

Open the Tests tab → scroll to the Set Variables section

2

Click + Add

3

Select the source (jsonpath, header, body, or regex)

4

Enter the property — JSONPath expression, header name, or regex pattern

5

Enter the variableName — the {{name}} to save as

6

Toggle enabled on/off — disabled rules are skipped during extraction

Click the × button to delete a rule.

JSONPath Examples

Common JSONPath patterns for extracting values from JSON responses:

JSONPathExtracts
$.tokenTop-level field
$.data.user.idNested field
$.items[0].nameFirst array item's field
$.items[*].idAll IDs from array (saved as array)
$.headers['content-type']Bracket notation for special characters

Results

Extraction results appear in the Test Results tab as "Set Variable" log entries. Each entry shows:

variableName

The target variable name

source

Which extraction source was used

found

Whether the path/property matched

saved

Whether the value was written to the environment

Successful extraction shows the saved value and environment name
If the path doesn't match, found=false — nothing is saved to the environment

Request Chaining

The key use case for Set Variables: passing data between requests in sequential collection runs.

Example: Auth token chaining

1

POST /auth/login

Set Variable: source=jsonpath, property=$.access_token, variableName=token

2

GET /users

Auth: Bearer {{token}} — uses the extracted token automatically

Important: Request chaining only works in sequential collection run mode. Parallel mode uses separate environment copies per request, so extracted variables are not shared between requests.

Also works with manual sends — once a variable is extracted and saved, it stays in the active environment and is available for all future requests in that session.

Next

Ko-fi