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.
Scopes
Section titled “Scopes”| Scope | Defined in | Lifetime |
|---|---|---|
| Collection | The collection itself | Always available within the collection |
| Environment | The active environment .bru file | Available while that environment is active |
| Workspace | The workspace | Shared across collections in the workspace |
| Runtime | Set by scripts at send time | Exists 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.
Resolution precedence
Section titled “Resolution precedence”When the same variable name exists in more than one scope, the most specific value wins:
runtime > environment > collection > workspaceA 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.
Cycle detection
Section titled “Cycle detection”Variables can reference other variables:
host = api.example.combase_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.
Mock-data functions
Section titled “Mock-data functions”Vegha provides built-in functions that generate fresh values each time a request is sent. Reference them like variables, prefixed with $:
| Function | Returns |
|---|---|
{{$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}}}