VariablesCollection Variables

Collection Variables

Collection variables are variables that are scoped to a specific collection. They are useful for storing variables that are used across multiple requests in a collection.

Creating a Collection Variable

  • Go to Collection Settings
  • Go to the Variables tab
  • Add your variable name, value in the Pre Request Vars section
  • Save your changes

Collection Variables

Using a Collection Variable

You can use the {{varName}} syntax to use a collection variable in a request.

Collection Variables Usage

Access Collection Variable inside scripts

You can also use the bru.getCollectionVar() function to get the value of a runtime variable and use it inside your pre request scripts.

let namespace = bru.getCollectionVar("namespace");

Import/Export Collection Variables

You can import and export collection variables to share them across teams or back them up for later use.

Accessing Import/Export Options

  1. Go to the Environments section (top right corner).

No-Environment

  1. Click on Configure to access the environment settings.

  2. You will see the Import and Export options in the bottom left corner.

Export Option

Importing Environment Variables

The import feature accepts environment files in both Bruno and Postman formats:

  1. Click on the Import button.
  2. Select the environment file you want to import
  3. The variables will be added to your collection.

Exporting Environment Variables

  1. Click on the Export button.
  2. If you have multiple environments, select which environments you want to export.
  3. Choose the location where you want to save the exported JSON file.

Export Collection Environment Location

  1. The environment variables will be saved as a JSON file that can be shared or backed up.
⚠️

Secret variables (variables marked as secret) will not be included in the exported JSON file for security reasons.