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:

SyntaxSourceLifetimeUse For
{{flow.varName}}Flow Store + ExtractionsSingle flow run (ephemeral)Tokens, IDs, dynamic response data
{{varName}}Group EnvironmentsPersistent (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:

  1. 1Select a step and open the Processors tab
  2. 2Write a post-response script to capture values from the response
  3. 3Use tg.flow.set(key, value) for ephemeral values (per-run) or tg.environment.set(key, value) for persistent values (saved to disk)
  4. 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:

SourceExpressionExample
JSON PathDot notation path into the response body. Supports array indexing.data.token
HeaderResponse header name (case-insensitive)X-Request-Id
RegexRegular expression applied to the response body. First capture group is used, or the full match if no capture group.id":(\d+)
Status CodeThe 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:

tg.flow.set(key, value)Store a value in the flow store (all values are converted to strings)
tg.flow.get(key)Retrieve a value (returns undefined if not set)
tg.flow.has(key)Check if a key exists (returns boolean)

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. 1. Live environment context (values set via tg.environment.set() in scripts)
  2. 2. Static environment variables (defined in the environment manager)

{{flow.varName}} (Flow Variables):

  1. 1. Flow Store (values set via tg.flow.set() in scripts)
  2. 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:

  1. 1Right-click a Flow Group in the sidebar → Environments
  2. 2Add environments (e.g., "Development", "Staging", "Production")
  3. 3Define variables for each environment (e.g., base_url, api_key)
  4. 4Select the active environment from the dropdown in the Action Bar

Example Environment Setup:

VariableDevelopmentStagingProduction
base_urlhttp://localhost:3000https://staging.api.comhttps://api.com
api_keydev-key-123stg-key-456prod-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

FeatureEnvironment
{{varName}}
Extraction
{{flow.varName}}
Flow Store
tg.flow.set()
DefinedBefore executionDuring execution (post-response)During execution (scripts)
ScopeAll flows in the groupCurrent flow runCurrent flow run
PersistenceSaved to diskEphemeral (per iteration)Ephemeral (per iteration)
Referenced As{{varName}}{{flow.varName}}{{flow.varName}}
Prioritytg.environment.set() > staticFallback if no Flow Store valueHighest (overrides extractions)
Best ForBase URLs, API keys, static configSimple response valuesComputed/transformed values