Skip to main content

Variable Interpolation Syntax

Welcome to the Variable Interpolation Syntax documentation!

Rumour features a powerful, lightweight string interpolation engine that allows you to inject dynamic variables into almost any part of your .toml request definitions.

1. The Double-Brace Syntax

To inject a variable into a string, wrap the exact variable name in double curly braces: {{variable_name}}.

Rumour's engine scans your .toml file and replaces these placeholders at runtime before the request is sent over the network.

Valid Injection Points

You can use the interpolation syntax inside:

  • The [request] table: url
  • The [headers] table: header values
  • The [params] table: query string values
  • The [body] table: inside the raw payload string

Example:

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

[headers]
Authorization = "Bearer {{auth_token}}"

[body]
type = "json"
raw = '{"email": "{{user_email}}"}'

2. Invalid Injection Points

For safety and determinism, Rumour's engine does not evaluate interpolation in the [assert] block or the [extract] block. Assertions must be statically defined to ensure predictable test boundaries, and extractions are the source of variables, not the destination.

Invalid Example (Will Fail):

[assert]
status = 200
# INVALID: You cannot use interpolation here
body_contains = "{{expected_response_text}}"

3. The {{random}} Keyword

Rumour provides a special reserved keyword: {{random}}.

Every time a node is executed, Rumour generates a unique alphanumeric string for that specific execution run. This is incredibly useful for generating unique emails or testing endpoints that enforce uniqueness constraints.

[body]
raw = '{"username": "test_user_{{random}}"}'

(Note: The {{random}} value is re-generated for every request node. If you need the exact same random string to persist across multiple requests, you should generate it in a pre_request Rhai script and export it, or extract an ID from the first response).

4. Escaping Braces

If you are sending a payload that actually needs to contain literal {{ or }} characters (for example, if you are testing an API that accepts Jinja templates or Vue.js code), Rumour currently assumes any double brace is a variable attempt.

If a variable is not found in the resolution hierarchy (CLI -> Local -> Env -> Extracted), Rumour will fail the pre-flight check with a Missing Variable error rather than sending the raw braces over the network.

If you must send literal double braces, you should use a pre_request Rhai script to dynamically construct the body and assign it to request.body.