Skip to content
Vegha Docs

Variable Types

Vegha resolves {{variable}} references from several scopes. Knowing which scope a value comes from — and which one wins when names collide — helps you organize values predictably.

ScopeDefined inLifetime
CollectionThe collection itselfAlways available within the collection
EnvironmentThe active environment .bru fileAvailable while that environment is active
WorkspaceThe workspaceShared across collections in the workspace
RuntimeSet by scripts at send timeExists for the current run

Runtime variables are created by pre-request or post-response scripts with bru.setVar. They are useful for passing values between requests — for example extracting a token from one response and using it in the next.

When the same variable name exists in more than one scope, the most specific value wins:

runtime > environment > collection > workspace

A runtime variable set by a script overrides everything else for the current run. If no scope defines the name, the reference resolves to an empty value.

Variables can reference other variables:

host = api.example.com
base_url = https://{{host}}

If references form a loop — a points to b and b points back to a — Vegha detects the cycle and reports an error instead of looping forever.

Vegha provides built-in functions that generate fresh values each time a request is sent. Reference them like variables, prefixed with $:

FunctionReturns
{{$guid}}A random GUID
{{$timestamp}}The current Unix timestamp
{{$randomInt}}A random integer

Use them inline anywhere a variable works:

{
"request_id": "{{$guid}}",
"sent_at": {{$timestamp}}
}