Inherited Headers
Inherited headers let you define HTTP headers once in a collection config file and have them automatically applied to every request in that directory and its subdirectories.
How It Works
Place a [headers] section in any .config.toml file. Every request in that folder (and subfolders) automatically receives those headers.
# api/api.config.toml
[headers]
Authorization = "Bearer {{access_token}}"
Content-Type = "application/json"
X-API-Version = "2"
All requests under api/ will have these three headers injected automatically.
Override Rules
| Priority | Source |
|---|---|
| 1 (Highest) | Request-level [headers] in the .toml file |
| 2 | Nearest parent .config.toml headers |
| 3 | Further-up parent .config.toml headers |
If a request defines Content-Type = "text/plain" locally, that overrides the Content-Type = "application/json" from the parent config.
Dynamic Values
Header values fully support variable interpolation:
[headers]
Authorization = "Bearer {{vault.api_token}}"
X-Request-ID = "{{random}}"
X-Session = "{{session_id}}"
CLI Header Overrides
# Override Authorization for this run only
rumour run auth/ --header "Authorization: Bearer my_token"
# Add a debug header to all requests
rumour run api/ --header "X-Debug: true"
--header values override inherited headers from any collection config.
Example
Let's set up a test workspace to see inherited headers in action against our mock server.
First, initialize a workspace (if you haven't already from the previous tutorial) and scaffold a new users collection using the CLI:
# Skip the init step if you already created the workspace in the previous tutorial
rumour init config_examples
cd config_examples
# Scaffold the new collection
rumour new users -y
This generates the directory structure. Update the generated files to match the layout below:
File Layout
config_examples/
├── workspace.env.toml
├── config_examples.config.toml
└── users/
├── users.config.toml
└── requests/
└── get_user.toml
workspace.env.toml
base_url = "http://localhost:4000/api/v2"
config_examples.config.toml
[headers]
Accept = "application/json"
X-Powered-By = "Rumour"
users/users.config.toml
[headers]
X-Service = "users"
users/requests/get_user.toml
name = "verify_inherited_headers"
[request]
method = "GET"
url = "{{base_url}}/users/1"
[assert]
status = 200
[assert.json."id"]
equal = 1
[assert.json."username"]
contains = "dev_lead"
When get_user.toml runs, it carries:
AcceptandX-Powered-Byfromconfig_examples.config.toml(top-level)X-Servicefromusers/users.config.toml(directory-level)- No duplication in the request file itself
Run
$ rumour run ./users/requests/ -v
Output
$ rumour run ./users/requests/ -v
GET http://localhost:4000/api/v2/users/1
Header: Accept: application/json
Header: X-Service: users
Header: X-Powered-By: Rumour
URL: http://localhost:4000/api/v2/users/1
✓ SUCCESS: ./users/requests/get_user.toml (9ms)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 1 │
│ Successful: 1 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 12ms │
╰──────────────────────────────────────────────────────────────────────────╯
✓ Successful Requests:
- ./users/requests/get_user.toml [200] [12ms]
Actionable Recommendations:
→ Run with --json to export this report for your CI/CD pipeline.
Explanation
When the get_user.toml request is executed, the verbose output (-v) shows the final HTTP request headers:
Accept: application/jsonandX-Powered-By: Rumourare successfully resolved and inherited from the rootconfig_examples.config.toml.X-Service: usersis inherited from the subdirectory-levelusers/users.config.toml.
All inherited headers from different folder levels are merged, ensuring complete reuse without any repetitive declarations in the request files.