Pre-request scripts let you generate fresh values immediately before an HTTP request is dispatched — without touching your saved environment. Each script rule is a small template expression that is evaluated at send time and injected into the active variable set for that single request. This is ideal for anything that must be unique or time-sensitive per request: nonce values, HMAC timestamps, test email addresses, or randomly scoped identifiers that would become stale if stored as static environment variables.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JonathanHerSa/xolo-api-hub/llms.txt
Use this file to discover all available pages before exploring further.
Script Format
Pre-request scripts are stored as a JSON array on the request record (columnpreScriptsJson). Each element is an object with two fields:
| Field | Type | Description |
|---|---|---|
key | String | The variable name that will be injected |
value | String | A template string using {{variable}} syntax |
value field supports the full VariableParser syntax, including all built-in dynamic helpers such as {{$timestamp}}, {{$guid}}, and {{$randomEmail}}.
key or empty value field are silently skipped during execution.
Execution
ScriptExecutor.executePreScripts() is called by RequestPipeline (and by CollectionRunnerService for each step in a collection run) before any headers, parameters, or the URL are resolved against the variable map.
Map<String, String>. The caller (RequestPipeline or CollectionRunnerService) merges the result into the working variable map with addAll, so pre-script values override any environment variable with the same name for the duration of that request.
Internal flow
- Parse
preScriptsJsonas a JSON array. - For each
{key, value}rule, callVariableParser.parse(value, baseVars). - Store the resolved string under
keyin the results map. - Return the full results map to the caller.
AppLogger.warn() and execution continues with the remaining rules.
Using Pre-Script Values
The computed variables are available everywhere in the same request immediately afterexecutePreScripts() returns — including the URL, all headers, all query parameters, and the request body. For example:
RequestPipeline calls VariableParser.parse() on any of those fields, every occurrence of {{requestId}} in the same request resolves to the same freshly generated UUID.
Pre-scripts only run for the current request and do not permanently modify the environment. The computed values exist only in the in-memory working variable map for the duration of that single send operation. To persist a value across multiple requests, use a post-response script to store it in the active environment.
Adding a Pre-Request Script in the UI
Open the Scripts tab
With a request open in the composer, tap the Scripts tab in the request editor tab bar.
Switch to Pre-Request
The Scripts tab contains two sub-tabs: Pre-Request and Post-Request. Select Pre-Request.
Add a rule
Tap Add (the
+ button in the top-right of the Pre-Request section). A new empty row appears with two fields: a variable name field and a value/template field.Enter the variable name and template
In the left field, type the variable name (e.g.,
requestId). In the right field, enter the template expression (e.g., {{$guid}}). The field uses a monospace font and supports any VariableParser expression.