Environments
An environment lets you reuse one collection against multiple targets — for example local, staging, and production — by swapping a named set of values.
What an environment is
Section titled “What an environment is”An environment is a set of name/value pairs stored in its own .bru file. Each pair becomes a variable you can reference with {{name}} anywhere a request is built.
A typical environment defines values like:
| Variable | Local | Production |
|---|---|---|
base_url | http://localhost:8080 | https://api.example.com |
api_key | dev-key | {{prod_key}} |
Creating an environment
Section titled “Creating an environment”Create a new environment and add the name/value pairs you need. Because an environment is just a .bru file, it lives alongside your collection and can be versioned with it.
You can keep environments per collection (specific to one project) or as global environments shared across collections.
The environment picker
Section titled “The environment picker”Use the environment picker to choose the active environment. Only one environment is active at a time, and its values are used when requests are sent. Switching the picker instantly retargets every {{variable}} reference in the collection.
You can also run with no environment selected, in which case only collection, workspace, and runtime variables resolve.
Using {{variable}} references
Section titled “Using {{variable}} references”Once an environment is active, reference its variables anywhere with double braces:
URL
{{base_url}}/v1/ordersHeader
Authorization: Bearer {{access_token}}Body
{ "region": "{{region}}", "tenant": "{{tenant_id}}"}Auth fields — environment variables work in the Authorization tab too, so you can keep credentials out of individual requests.
Environments and other scopes
Section titled “Environments and other scopes”Environment variables are one of several scopes. When the same name exists in more than one scope, Vegha resolves it by precedence. See Variable types for the full resolution order and the available scopes.