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:
{{variableName}}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:
Open the Tests tab → scroll to the Set Variables section
Click + Add
Select the source (jsonpath, header, body, or regex)
Enter the property — JSONPath expression, header name, or regex pattern
Enter the variableName — the {{name}} to save as
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:
| JSONPath | Extracts |
|---|---|
| $.token | Top-level field |
| $.data.user.id | Nested field |
| $.items[0].name | First array item's field |
| $.items[*].id | All 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:
The target variable name
Which extraction source was used
Whether the path/property matched
Whether the value was written to the environment
found=false — nothing is saved to the environmentRequest Chaining
The key use case for Set Variables: passing data between requests in sequential collection runs.
Example: Auth token chaining
POST /auth/login
Set Variable: source=jsonpath, property=$.access_token, variableName=token
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.