Skip to main content

Inherited Params

The [params] section in a collection config file injects URL query parameters into every request in that directory. This is ideal for API versioning, feature flags, or debug parameters that must be present on all requests.

Defining Inherited Params​

# api/api.config.toml

[params]
api_version = "v2"
format = "json"
debug = "false"

All requests under api/ automatically get ?api_version=v2&format=json&debug=false appended to their URLs.

note

All parameter values must be strings in TOML. Use debug = "false" not debug = false.

Override Rules​

PrioritySource
1 (Highest)Request-level [params] in the .toml file
2Nearest parent .config.toml params
3Further-up parent .config.toml params

If a request defines api_version = "v3" locally, that overrides the inherited v2.

Variable Interpolation​

Param values support full variable resolution:

[params]
client_id = "{{vault.oauth_client_id}}"
locale = "{{user_locale}}"
version = "{{api_version}}"

Example​

Let's set up a test workspace to see inherited parameters in action against our mock server.

First, initialize a workspace (skip this step if you already created it in 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/
└── requests/
├── get_alpha_team.toml
└── get_beta_team.toml

workspace.env.toml​

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

config_examples.config.toml​

[params]
team = "alpha"

users/requests/get_alpha_team.toml​

name = "verify_inherited_params_alpha"

[request]
method = "GET"
url = "{{base_url}}/users"

[assert]
status = 200

[assert.json."[0].team"]
equal = "alpha"

[assert.json."[1].team"]
equal = "alpha"

[assert.json."[2]"]
exists = false

users/requests/get_beta_team.toml​

name = "verify_overridden_params_beta"

[request]
method = "GET"
url = "{{base_url}}/users"

[params]
team = "beta"

[assert]
status = 200

[assert.json."[0].team"]
equal = "beta"

[assert.json."[1]"]
exists = false

Run​

$ rumour run ./users/requests/ -v

Output​

$ rumour run ./users/requests/ -v

GET http://localhost:4000/api/v2/users
URL: http://localhost:4000/api/v2/users?team=alpha
Query Param: team=alpha
✓ SUCCESS: ./users/requests/get_alpha_team.toml (18ms)
GET http://localhost:4000/api/v2/users
URL: http://localhost:4000/api/v2/users?team=beta
Query Param: team=beta
✓ SUCCESS: ./users/requests/get_beta_team.toml (6ms)

╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 2 │
│ Successful: 2 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 43ms │
╰──────────────────────────────────────────────────────────────────────────╯

✓ Successful Requests:
- ./users/requests/get_alpha_team.toml [200] [31ms]
- ./users/requests/get_beta_team.toml [200] [12ms]

Actionable Recommendations:
→ Run with --json to export this report for your CI/CD pipeline.

Explanation​

When the directory is executed, the team = "alpha" parameter from the config_examples.config.toml is injected automatically into get_alpha_team.toml, appending ?team=alpha to the URL. However, get_beta_team.toml defines a local team = "beta" parameter which takes priority and overrides the inherited value, appending ?team=beta to its URL. This demonstrates how you can share defaults while easily overriding them when necessary.