Post-response scripts close the loop between an API response and your next request. After every successful HTTP call, Xolo evaluates a set of JSONPath extraction rules against the response body and stores the matched values as environment variables. This is how you implement request chaining — for example, authenticating with a login endpoint, capturing the returned access token, and automatically injecting it as aDocumentation 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.
Bearer header in every subsequent request — without any manual copy-and-paste.
Script Format
Post-response scripts are stored as a JSON array on the request record (columnscriptsJson). Each element is an object with two fields:
| Field | Type | Description |
|---|---|---|
key | String | The environment variable name to store the extracted value under |
path | String | A JSONPath expression evaluated against the response body |
key or empty path are silently skipped.
JSONPath Syntax
Xolo uses thejson_path Dart package for JSONPath evaluation. Expressions follow standard JSONPath notation:
| Pattern | Meaning |
|---|---|
$.field | Top-level field named field |
$.nested.field | Nested field access |
$.array[0].field | First element of an array, then a field |
$.items[*].id | All id values across every element of items |
ScriptExecutor uses the first match. If the path matches nothing, the variable is set to the sentinel value '[No Match]' rather than being omitted, so you can immediately see in the UI that the extraction failed.
ScriptExecutor.testPostScripts() Signature
CollectionRunnerService._applyPostScripts()) calls XoloRepository.upsertVariable() for every successfully matched value.
Live Testing
The Scripts tab provides a Test button (▶) in the Post-Request section header. Tapping it callstestPostScripts() against the most recently received response body — the request is not re-sent. Each extraction rule row displays the matched result inline beneath it, highlighted in orange for a match or red for an error, so you can iterate on your JSONPath expressions rapidly without consuming API rate limits.
Request Chaining
When you send a request from the composer, successfully matched values are upserted into the active environment viaXoloRepository.upsertVariable(). This means subsequent requests in the same session will resolve {{authToken}} (or whatever key you chose) from the environment automatically, without any additional configuration.
A complete token-chaining workflow looks like this:
authToken and currentUserId are live in the environment. Any subsequent request can reference them:
Collection Runner Integration
When the collection runner executes a step, post-scripts run after assertions are evaluated and before the next step begins. Extracted values are merged into the sharedworkingVars map that flows through the entire run:
_applyPostScripts both updates workingVars for the next iteration of the loop and persists each matched value to the database via upsertVariable, so the extracted token survives even if the run is interrupted.
Variable extraction from one step flows into the next, enabling full authentication + resource workflows. For example: step 1 logs in and captures
{{authToken}}; step 2 creates a resource using that token and captures {{resourceId}}; step 3 fetches and asserts on that resource.