Scripting API

v1.0.0-SEFebruary 17, 2026

Tigrister's scripting engine gives you full programmatic control over your HTTP requests. The tg object available in every pre-request and post-response script lets you read and modify requests, inspect responses, manage environment variables, and share data across flow steps.

The tg Object

Four namespaces, each serving a distinct purpose:

  • tg.request — Access and modify the HTTP request. Mutable in pre-scripts, read-only in post-scripts.
  • tg.response — Access response data including status, headers, body, and timing. Available only in post-scripts.
  • tg.environment — Read and write environment variables. Changes are persisted immediately and available in subsequent requests.
  • tg.flow — Read and write flow-scoped variables for cross-step data sharing. Only available inside Flow Runner execution.

Request Modification

Pre-scripts can modify the request before it's sent — add headers, change the URL, or rewrite the body dynamically.

Property / MethodTypePre-ScriptPost-Script
tg.request.urlstringread / writeread-only
tg.request.methodstringread-onlyread-only
tg.request.headersobjectread (copy)read (copy)
tg.request.bodystring | undefinedread / writeread-only
tg.request.setHeader(key, value)voidadds/updates header
tg.request.removeHeader(key)voidremoves header
// Pre-script: Add dynamic auth header
const token = tg.environment.get('auth_token');
if (token) {
  tg.request.setHeader('Authorization', 'Bearer ' + token);
}

Response Inspection

Post-scripts have full access to the response — status code, headers, body, and performance timing.

Property / MethodTypeDescription
tg.response.statusnumberHTTP status code
tg.response.statusTextstringHTTP status text
tg.response.headersobjectResponse headers
tg.response.bodystringRaw response body
tg.response.json()anyCached JSON parser — safe to call multiple times
tg.response.timingobjectBreakdown: total, dns, tls, ttfb (ms)
// Post-script: Extract tokens from login response
if (tg.response.status === 200) {
  const data = tg.response.json();
  tg.environment.set('auth_token', data.access_token);
  tg.environment.set('refresh_token', data.refresh_token);
}

Environment Variables

Variables set with tg.environment.set() are persisted immediately and referenced as {{varName}} in URL, headers, body, params, and auth fields.

MethodDescription
tg.environment.get(key)Returns value or undefined
tg.environment.set(key, value)Sets and persists immediately
tg.environment.has(key)Returns true if exists

Works across all contexts — standalone requests, project requests, and flow steps. The active environment depends on context: global, project, or flow group.

Flow Variables

Share data between flow steps with ephemeral variables. Unlike environment variables, flow variables exist only for the current flow run.

MethodDescription
tg.flow.get(key)Returns value or undefined
tg.flow.set(key, value)Sets for current iteration
tg.flow.has(key)Returns true if exists

Referenced as {{flow.varName}} in any subsequent step's URL, headers, body, or assertions.

// Step 1 post-script: Extract user data
const data = tg.response.json();
tg.flow.set('userId', String(data.id));
tg.flow.set('token', data.token);

// Step 2 URL: {{base_url}}/api/users/{{flow.userId}}
// Step 2 Header: Authorization: Bearer {{flow.token}}

Additional Globals

GlobalDescription
console.log() / warn() / error()Log to Script Output panel (capped at 1000 chars)
fetch(url, options)Make HTTP requests from within scripts
setTimeout(fn, ms)Delay execution within a script

All scripts have a 30-second execution limit.

Tigrister's scripting API turns your API client into a full automation platform — from simple token extraction to complex multi-step workflows with conditional logic and data chaining.