Skip to main content
Bruno provides a powerful variable system with multiple scopes and precedence levels. Understanding how variables work is essential for building dynamic, maintainable API collections.

Variable Scopes

Bruno supports six variable scopes, each with different use cases and lifetimes:

Environment

Environment-specific values

Global Environment

Shared across all environments

Collection

Collection-wide variables

Folder

Folder-level variables

Request

Request-specific variables

Runtime

Temporary execution variables

Variable Precedence

When multiple scopes define the same variable, Bruno uses the following precedence order (highest to lowest):
Runtime variables have the highest precedence and will override all other scopes.

Environment Variables

Environment variables are specific to each environment (dev, staging, production, etc.) and are the most commonly used variable type.

Setting Environment Variables

  1. Click the environment dropdown
  2. Select “Configure”
  3. Add or edit variables
  4. Save changes

Persistent Variables

By default, variables set via scripts are temporary. Use the persist option to save them permanently:
Persistent variables must be strings. Objects and arrays cannot be persisted.

Global Environment Variables

Global environment variables are shared across all environments, useful for values that don’t change between dev/staging/production.

Runtime Variables

Runtime variables are temporary and exist only during request execution. They have the highest precedence and are perfect for passing data between requests.

Basic Usage

Passing Data Between Requests

1

Request 1: Login

2

Request 2: Get Profile

3

Request 3: Update Profile

Collection Variables

Collection variables are defined at the collection level and are available to all requests in the collection.

In collection.bru

In Scripts

Folder Variables

Folder variables are inherited by all requests within a folder and its subfolders.
Folder variables can only be read in scripts, not modified. Define them in folder configuration.

Request Variables

Request variables are specific to a single request and have the lowest precedence among regular variables.

Variable Interpolation

Use {{variableName}} syntax to interpolate variables in requests:

In URLs

In Headers

In Body

Programmatic Interpolation

Process Environment Variables

Access system environment variables from your OS:

Variable Naming Rules

Variable names must follow these rules:
  • Only alphanumeric characters, hyphens (-), underscores (_), and dots (.)
  • No spaces or special characters
  • Case-sensitive

Valid Names

Invalid Names

Advanced Patterns

Conditional Variables

Variable Transformations

Dynamic Variable Generation

Variable Cleanup

Common Patterns

Best Practices

1

Choose the Right Scope

  • Use environment variables for environment-specific values (API keys, URLs)
  • Use runtime variables for passing data between requests
  • Use collection variables for shared constants
  • Use global variables for truly universal values
2

Use Descriptive Names

3

Clean Up Sensitive Data

4

Document Variable Usage

Add comments explaining variable purposes and expected values:

Scripting

Master Bruno’s scripting capabilities

Environments

Configure and manage environments

Assertions

Test and validate API responses

Workflows

Build complex request sequences