Skip to main content

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

PrioritySource
1 (Highest)Request-level [headers] in the .toml file
2Nearest parent .config.toml headers
3Further-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

The following example was verified against the local mock server.

File Layout

config_examples/02_inherited_headers/
├── workspace.env.toml
├── api.config.toml
└── users/
├── users.config.toml
└── get_user.toml

workspace.env.toml

base_url = "http://localhost:4000/api/v2"

api.config.toml

[headers]
Accept = "application/json"
X-Powered-By = "Rumour"

users/users.config.toml

[headers]
X-Service = "users"

users/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."email"]
contains = "test.com"

When get_user.toml runs, it carries:

  • Accept and X-Powered-By from api.config.toml (top-level)
  • X-Service from users/users.config.toml (directory-level)
  • No duplication in the request file itself

Run

rumour run ./config_examples/02_inherited_headers/users/ -v

Output

~/workspace/testing main ❯ rumour run ./config_examples/02_inherited_headers/users/ -v
GET http://localhost:4000/api/v2/users/1
Header: X-Powered-By: Rumour
Header: X-Service: users
Header: Accept: application/json
URL: http://localhost:4000/api/v2/users/1
✓ SUCCESS: /home/bugsfounder/workspace/testing/config_examples/02_inherited_headers/users/get_user.toml (1ms)
✓ ./config_examples/02_inherited_headers/users/ → PASS (1 Pass, 0 Fail, 0 Skip)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 1
│ Successful: 1
│ Failed: 0
│ Skipped: 0
│ Success Rate: 100.0% │
│ Total Time: 2ms │
╰──────────────────────────────────────────────────────────────────────────╯

✓ Successful Requests:
- /home/bugsfounder/workspace/testing/config_examples/02_inherited_headers/users/get_user.toml [200] [2ms]

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/json and X-Powered-By: Rumour are successfully resolved and inherited from the root api.config.toml.
  • X-Service: users is inherited from the subdirectory-level users/users.config.toml.

All inherited headers from different folder levels are merged, ensuring complete reuse without any repetitive declarations in the request files.