Variable Extraction
To build end-to-end integration workflows, requests often need to consume outputs produced by previous requests (such as API tokens, resource IDs, or headers). Rumour provides a powerful variable extraction system supporting both explicit path configuration and intelligent implicit auto-extraction.
1. Explicit Extraction Syntax
Explicit extraction rules are defined inside an [extract] block in your request TOML file. They map local variable names to specific parts of the response payload or headers:
[extract]
authToken = "json.access_token"
sessionExpiry = "json.expires_in"
serverHost = "header.host"
In this block, Rumour extracts:
authToken: from the JSON body keyjson->access_tokennested path.sessionExpiry: from the JSON body keyjson->expires_innested path.serverHost: from the HTTP response headerHost.
2. Setup Environment
To set up a test environment from scratch and replicate the workspace example, follow these steps:
A. Initialize the Workspace
Create a new directory and initialize a clean, zero-clutter Rumour workspace root:
mkdir extract_example
cd extract_example
rumour init
B. Scaffold Modular Collections
Scaffold two modular collections inside the workspace (auth and users) using the scaffolding tool:
rumour new auth
rumour new users
3. Directory Structure & File Contents
After setting up the workspace, your directory structure will look like this:
extract_example/
├── workspace.env.toml
├── extract_example.config.toml
├── extract_example.suite.toml
├── auth/
│ ├── auth.config.toml
│ ├── auth.env.toml
│ ├── auth.suite.toml
│ └── requests/
│ └── login.toml
└── users/
├── users.config.toml
├── users.env.toml
├── users.suite.toml
└── requests/
└── get_users.toml
Here are the complete contents for each file in this setup:
A. Workspace Level Files
workspace.env.toml
Defines base variables for the workspace suite.
# workspace.env.toml
[variables]
base_url = "http://localhost:4000"
"env.ENV_STAGE" = "staging"
B. auth Collection Files
auth/requests/login.toml
Sends login parameters, explicitly extracting the server software header and the echoed token value.
# auth/requests/login.toml
[request]
method = "POST"
url = "{{base_url}}/post"
[body]
type = "json"
raw = '{"username": "admin", "token": "session_secret_xyz123"}'
[extract]
token = "json.token"
server_software = "header.server"
C. users Collection Files
users/requests/get_users.toml
Declares a dependency on login.toml and references the extracted variables.
# users/requests/get_users.toml
[dependencies]
"../../auth/requests/login.toml" = "token"
[request]
method = "GET"
url = "{{base_url}}/headers"
[headers]
Authorization = "Bearer {{../../auth/requests/login.token}}"
X-Server-Target = "{{../../auth/requests/login.server_software}}"
[variables]
client_name = "RumourTestAgent/2.0"
4. Run the Requests & Outputs
When executing get_users.toml, Rumour parses dependencies, runs login.toml first, extracts the variables, and substitutes them into get_users.toml.
Command
rumour run extract_example/users/requests/get_users.toml -tv
Output Trace
POST http://localhost:4000/post
URL: http://localhost:4000/post
Body (json): {"username": "admin", "token": "session_secret_xyz123"}
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/auth/requests/login.toml (1043ms)
GET http://localhost:4000/headers
Header: Authorization: Bearer session_secret_xyz123
Header: X-Server-Target: rumour-mock-server
URL: http://localhost:4000/headers
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/users/requests/get_users.toml (249ms)
✓ extract_example/users/requests/get_users.toml → PASS (2 Pass, 0 Fail, 0 Skip)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 2 │
│ Successful: 2 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 1296ms │
╰──────────────────────────────────────────────────────────────────────────╯
✓ Successful Requests:
- /home/bugsfounder/workspace/testing/extract_example/auth/requests/login.toml [200] [1044ms]
- /home/bugsfounder/workspace/testing/extract_example/users/requests/get_users.toml [200] [251ms]
5. Explicit Extraction Selectors
Rumour supports two selector modes: JSON paths and Header fields.
A. JSON Path Selectors
JSON selectors navigate through JSON response bodies using dot-notated paths.
- Property Navigation:
user.profile.emailextracts from:{"user": {"profile": {"email": "developer@example.com"}}} - Array Indexing: You can use numbers in your dot-separated path to access elements inside arrays. For example,
users.1.idextracts theidof the second element in theusersarray.
JSON Selector Evidence
Here is a live request (test_json.toml) fetching a structured payload from /json and extracting properties:
# test_json.toml
[request]
method = "GET"
url = "{{base_url}}/json"
[headers]
User-Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
[extract]
author = "slideshow.author"
second_slide = "slideshow.slides.1.title"
Verifying downstream via test_json_verify.toml:
# test_json_verify.toml
[dependencies]
"./test_json.toml" = ["author", "second_slide"]
[request]
method = "GET"
url = "{{base_url}}/anything"
[headers]
User-Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
X-Verify-Author = "{{author}}"
X-Verify-Slide = "{{second_slide}}"
Terminal Run Trace:
rumour run extract_example/users/requests/test_json_verify.toml -tv
GET http://localhost:4000/json
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/users/requests/test_json.toml (2621ms)
GET http://localhost:4000/anything
Header: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Header: X-Verify-Slide: Overview
Header: X-Verify-Author: Yours Truly
URL: http://localhost:4000/anything
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/users/requests/test_json_verify.toml (529ms)
✓ /home/bugsfounder/workspace/testing/extract_example/users/requests/test_json_verify.toml → PASS (2 Pass, 0 Fail, 0 Skip)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 2 │
│ Successful: 2 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 3151ms │
╰──────────────────────────────────────────────────────────────────────────╯
✓ Successful Requests:
- /home/bugsfounder/workspace/testing/extract_example/users/requests/test_json.toml [200] [2621ms]
- /home/bugsfounder/workspace/testing/extract_example/users/requests/test_json_verify.toml [200] [529ms]
Actionable Recommendations:
→ Run with --json to export this report for your CI/CD pipeline.
B. Header Selectors
To extract from HTTP response metadata, prepend the selector path with the header. or headers. prefix.
- Both
header.<name>andheaders.<name>are supported as aliases. - The header name matching is case-insensitive (e.g.,
header.Content-Type,headers.content-type, andheader.CONTENT-TYPEbehave identically).
Header Selector Evidence (Rumour Mock Server)
Here is a live request (test_headers.toml) fetching a custom response header and extracting it:
# test_headers.toml
[request]
method = "GET"
url = "{{base_url}}/response-headers?X-Custom-Server=RumourTestServer"
[headers]
User-Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
[extract]
custom_server = "header.x-custom-server"
content_type = "header.Content-Type"
Verifying downstream via test_headers_verify.toml:
# test_headers_verify.toml
[dependencies]
"./test_headers.toml" = ["custom_server", "content_type"]
[request]
method = "GET"
url = "{{base_url}}/anything"
[headers]
User-Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
X-Verify-Server = "{{custom_server}}"
X-Verify-Type = "{{content_type}}"
Terminal Run Trace:
rumour run extract_example/users/requests/test_headers_verify.toml -tv
GET http://localhost:4000/response-headers?X-Custom-Server=RumourTestServer
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/users/requests/test_headers.toml (1583ms)
GET http://localhost:4000/anything
Header: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Header: X-Verify-Server: RumourTestServer
Header: X-Verify-Type: application/json
URL: http://localhost:4000/anything
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/users/requests/test_headers_verify.toml (1198ms)
✓ /home/bugsfounder/workspace/testing/extract_example/users/requests/test_headers_verify.toml → PASS (2 Pass, 0 Fail, 0 Skip)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 2 │
│ Successful: 2 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 2781ms │
╰──────────────────────────────────────────────────────────────────────────╯
✓ Successful Requests:
- /home/bugsfounder/workspace/testing/extract_example/users/requests/test_headers.toml [200] [1583ms]
- /home/bugsfounder/workspace/testing/extract_example/users/requests/test_headers_verify.toml [200] [1198ms]
Actionable Recommendations:
→ Run with --json to export this report for your CI/CD pipeline.
6. Intelligent Auto-Extraction (Implicit Extraction)
To simplify configurations, Rumour features an implicit auto-extraction engine. When any request completes successfully, Rumour automatically scans the JSON response body for common authentication, identity, and session properties, extracting them even if you have no [extract] block configured.
Pre-Registered Keywords
Rumour normalizes keys (removing casing and separators like _ or -) and matches them against the following categories:
| Category | Canonical Variable Name | Recognized Aliases / Patterns |
|---|---|---|
| Authentication | accessToken | token, access_token, auth_token, authToken, jwt, bearer, api_key, apiKey, authorization, auth |
| Admin Auth | adminAccessToken | admin_token, adminAccessToken, admin_access_token, adminToken |
| Refresh Tokens | refreshToken | refresh_token, refreshToken, refresh |
| Identity | id | user_id, userId, uid, uuid, account_id, accountId, guid |
| Session | sessionId | session_id, sessionId, sid, session, csrf, xsrf, token_id, X-CSRF-TOKEN, X-XSRF-TOKEN |
| Metadata | version, status | v, ver, version, state, status |
Namespacing Rules
When a key is implicitly or explicitly extracted from a request (e.g., from login.toml), it is exposed to downstream files in two ways:
- Global/Direct Name: Captured as
accessTokenorid. - Namespaced Name: Prefixed with the file stem of the request, e.g.
login.accessTokenorlogin.id. This ensures that downstream files can uniquely select variables if multiple upstream requests extract the same key.
Intelligent Auto-Extraction Evidence (Rumour Mock Server)
Here is a live request (test_auto.toml) that performs a JSON POST with standard identifier keys inside the request body without declaring an [extract] block:
# test_auto.toml
[request]
method = "POST"
url = "{{base_url}}/post"
[headers]
User-Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
[body]
type = "json"
raw = '{"token": "intelligent_token_123", "user_id": "usr_999", "session_id": "sess_888"}'
Verifying downstream via test_auto_verify.toml:
# test_auto_verify.toml
[dependencies]
"./test_auto.toml" = ["accessToken", "id", "sessionId"]
[request]
method = "GET"
url = "{{base_url}}/anything"
[headers]
User-Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
X-Verify-Token-Global = "{{accessToken}}"
X-Verify-ID-Global = "{{id}}"
X-Verify-Session-Global = "{{sessionId}}"
Terminal Run Trace:
rumour run extract_example/users/requests/test_auto_verify.toml -tv
POST http://localhost:4000/post
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/users/requests/test_auto.toml (1165ms)
GET http://localhost:4000/anything
Header: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Header: X-Verify-Token-Global: intelligent_token_123
Header: X-Verify-ID-Global: usr_999
Header: X-Verify-Session-Global: sess_888
URL: http://localhost:4000/anything
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/users/requests/test_auto_verify.toml (1183ms)
✓ /home/bugsfounder/workspace/testing/extract_example/users/requests/test_auto_verify.toml → PASS (2 Pass, 0 Fail, 0 Skip)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 2 │
│ Successful: 2 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 2349ms │
╰──────────────────────────────────────────────────────────────────────────╯
✓ Successful Requests:
- /home/bugsfounder/workspace/testing/extract_example/users/requests/test_auto.toml [200] [1165ms]
- /home/bugsfounder/workspace/testing/extract_example/users/requests/test_auto_verify.toml [200] [1183ms]
Actionable Recommendations:
→ Run with --json to export this report for your CI/CD pipeline.
7. Referencing Extracted Variables
You can access extracted variables in downstream requests using two distinct syntaxes:
Option 1: Direct Dotted Relative Path
Access the variable by routing directly to the dependency's relative file location:
[headers]
Authorization = "Bearer {{../../auth/requests/login.token}}"
X-Server-Target = "{{../../auth/requests/login.server_software}}"
Option 2: Short Local Variable Mapping (Recommended)
You can declare a dependency mapping in your [dependencies] block to bind the relative request's exported value to a simple local variable name:
[dependencies]
"../../auth/requests/login.toml" = "token"
[headers]
Authorization = "Bearer {{token}}"
Declaring explicit dependency maps at the bottom or top of your request file namespaces your variables cleanly, making them easier to read and protecting them from collision conflicts if multiple upstream requests extract identically named variables.
8. Idempotent Fallback Handling
To support self-healing scenarios (such as resolving 409 Conflict errors during resource creation), Rumour features an idempotence fallback.
If a request fails or returns a response without the extracted field, Rumour falls back to the current local variable value of that name already stored in the execution scope instead of crashing. This allows subsequent assertions and healers to proceed using pre-existing values.
Fallback Safety Evidence (Rumour Mock Server)
Here is a live request (test_fallback.toml) defining a local variable, attempting to extract a non-existent key, and demonstrating the fallback safety:
# test_fallback.toml
[request]
method = "GET"
url = "{{base_url}}/json"
[headers]
User-Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
[variables]
fallback_val = "pre_defined_value"
[extract]
fallback_val = "slideshow.non_existent_key"
Verifying downstream via test_fallback_verify.toml:
# test_fallback_verify.toml
[dependencies]
"./test_fallback.toml" = ["fallback_val"]
[request]
method = "GET"
url = "{{base_url}}/anything"
[headers]
User-Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
X-Verify-Fallback = "{{fallback_val}}"
Terminal Run Trace:
rumour run extract_example/users/requests/test_fallback_verify.toml -tv
GET http://localhost:4000/json
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/users/requests/test_fallback.toml (3368ms)
GET http://localhost:4000/anything
Header: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Header: X-Verify-Fallback: pre_defined_value
URL: http://localhost:4000/anything
✓ SUCCESS: /home/bugsfounder/workspace/testing/extract_example/users/requests/test_fallback_verify.toml (738ms)
✓ /home/bugsfounder/workspace/testing/extract_example/users/requests/test_fallback_verify.toml → PASS (2 Pass, 0 Fail, 0 Skip)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 2 │
│ Successful: 2 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 4107ms │
╰──────────────────────────────────────────────────────────────────────────╯
✓ Successful Requests:
- /home/bugsfounder/workspace/testing/extract_example/users/requests/test_fallback.toml [200] [3368ms]
- /home/bugsfounder/workspace/testing/extract_example/users/requests/test_fallback_verify.toml [200] [738ms]
Actionable Recommendations:
→ Run with --json to export this report for your CI/CD pipeline.