Variables & Environments
How data flows between steps using flow variables, environment variables, and the scripting API.
Two Variable Systems
Tigrister has two distinct variable syntaxes for different purposes:
| Syntax | Source | Lifetime | Use For |
|---|---|---|---|
| {{flow.varName}} | Flow Store + Extractions | Single flow run (ephemeral) | Tokens, IDs, dynamic response data |
| {{varName}} | Group Environments | Persistent (saved to disk) | Base URLs, API keys, static config |
Recommendation: Use {{flow.varName}} for any value that comes from a response (tokens, IDs, timestamps). Reserve {{varName}} for values that stay the same across runs (base URLs, API keys).
Variable Extraction
Variable extraction lets you capture values from a step's response and make them available in subsequent steps. This is the core feature that enables request chaining.
Extracting Values:
- 1Select a step and open the Processors tab
- 2Write a post-response script to capture values from the response
- 3Use tg.flow.set(key, value) for ephemeral values (per-run) or tg.environment.set(key, value) for persistent values (saved to disk)
- 4Reference with {{flow.varName}} (ephemeral) or {{varName}} (persistent) in any subsequent step's URL, headers, body, or params
Extraction Sources
Each extraction has a name, a source type, and an expression:
| Source | Expression | Example |
|---|---|---|
| JSON Path | Dot notation path into the response body. Supports array indexing. | data.token |
| Header | Response header name (case-insensitive) | X-Request-Id |
| Regex | Regular expression applied to the response body. First capture group is used, or the full match if no capture group. | id":(\d+) |
| Status Code | The HTTP status code (no expression needed) | 200 |
JSON Path Examples:
data.user.id → nested object access
items[0].name → array index access
meta.pagination.next → deeply nested value
token → top-level field
If the path resolves to an object or array, the value is serialized via JSON.stringify(). String values are used as-is.
Using Flow Variables
Once a variable is extracted (or set via script), reference it in any subsequent step using {{flow.varName}}:
- •URL: {{base_url}}/users/{{flow.userId}}
- •Headers: Authorization: Bearer {{flow.token}}
- •Body: {"parent_id": "{{flow.parentId}}"}
- •Params: cursor={{flow.nextCursor}}
- •Assertions: response body data.id equals {{flow.userId}}
Note: Variables are resolved at runtime, just before each step executes. If a variable hasn't been extracted yet (e.g., the source step hasn't run), the placeholder {{flow.varName}} remains as-is in the request.
tg.flow Scripting API
In pre-request and post-response scripts, you can use the tg.flow API to share data between steps programmatically.
Available Methods:
Post-script Example (after login step):
const data = tg.response.json();
tg.flow.set("token", data.token);
tg.flow.set("userId", String(data.user.id));
tg.flow.set("role", data.user.role);
Pre-script Example (before a subsequent step):
if (tg.flow.has("token")) {
tg.request.setHeader("Authorization", "Bearer " + tg.flow.get("token"));
}
When to use tg.flow vs tg.environment: Use tg.flow.set() for values needed only during the current run (tokens, session IDs). Use tg.environment.set() for values that should persist across runs (saved to disk).
Variable Resolution Order
When a step is about to execute, variables are resolved in a specific order:
{{varName}} (Environment Variables):
- 1. Live environment context (values set via tg.environment.set() in scripts)
- 2. Static environment variables (defined in the environment manager)
{{flow.varName}} (Flow Variables):
- 1. Flow Store (values set via tg.flow.set() in scripts)
- 2. Extracted variables (from previously executed steps)
Note: Environment variables ({{varName}}) are resolved first, then flow variables ({{flow.varName}}). This means you can mix both in the same field: {{base_url}}/users/{{flow.userId}}
Flow Environments
Each Flow Group can have its own set of environments (e.g., dev, staging, prod) with environment-specific variables. These are referenced using {{varName}} (without the flow. prefix).
Setting Up Environments:
- 1Right-click a Flow Group in the sidebar → Environments
- 2Add environments (e.g., "Development", "Staging", "Production")
- 3Define variables for each environment (e.g., base_url, api_key)
- 4Select the active environment from the dropdown in the Action Bar
Example Environment Setup:
| Variable | Development | Staging | Production |
|---|---|---|---|
| base_url | http://localhost:3000 | https://staging.api.com | https://api.com |
| api_key | dev-key-123 | stg-key-456 | prod-key-789 |
With this setup, {{base_url}}/api/users resolves to http://localhost:3000/api/users in Development and https://api.com/api/users in Production.
Note: Values set via tg.environment.set(key, value) in scripts are persisted to disk and update the active environment permanently. Use this for values that should survive across flow runs.
Secret Variables
Variables can be marked as secret. Secret variable values are masked in the UI (shown as dots) and are not included when exporting. Use secrets for API keys, passwords, and tokens that should not be visible.
Variable Types Comparison
| Feature | Environment {{varName}} | Extraction {{flow.varName}} | Flow Store tg.flow.set() |
|---|---|---|---|
| Defined | Before execution | During execution (post-response) | During execution (scripts) |
| Scope | All flows in the group | Current flow run | Current flow run |
| Persistence | Saved to disk | Ephemeral (per iteration) | Ephemeral (per iteration) |
| Referenced As | {{varName}} | {{flow.varName}} | {{flow.varName}} |
| Priority | tg.environment.set() > static | Fallback if no Flow Store value | Highest (overrides extractions) |
| Best For | Base URLs, API keys, static config | Simple response values | Computed/transformed values |