Skip to main content

Overview

Bruno collections are directories containing .bru files. Collections can have:
  1. collection.bru - Collection-level settings and scripts
  2. folder.bru - Folder-level metadata files
  3. Environment files - Variable definitions for different environments

Collection Structure

Collection File

The collection.bru file defines collection-level settings that apply to all requests.

Basic Collection

Collection Blocks

Headers applied to all requests in the collection:
Default authentication mode for the collection:
Supported modes: none, basic, bearer, digest, awsv4, oauth2, wsse, apikey
Authentication credentials for the collection:
Variables set before each request:
Variables extracted after each response:
Script executed before each request:
Script executed after each response:
Tests run for all requests:
Collection documentation:

Complete Collection Example

Folder Files

The folder.bru file contains metadata for organizing requests within folders.
string
required
Display name for the folder
number
Sequence number for ordering folders

Folder Example

Environment Files

Environment files define variables for different environments (dev, staging, production).

Environment File Location

Environment files are stored in the environments/ directory:

Environment File Format

Environment Variables

Do not commit sensitive data like API keys or passwords to version control. Use local environments or secret management.

Development Environment

Staging Environment

Production Environment

Variable Precedence

Variables are resolved in the following order (highest to lowest priority):
  1. Request variables - Set in vars:pre-request within the request
  2. Environment variables - Set in the active environment file
  3. Collection variables - Set in collection.bru
  4. Built-in variables - System variables like {{$uuid}}
Request-level variables override environment and collection variables.

Variable Syntax

Enabling/Disabling Variables

Disabled variables (prefixed with ~) are not applied.

Local Variables

Variables prefixed with @ are local and not persisted:

Referencing Environment Variables

Environment variables in {{}} are resolved from:
  • Process environment variables
  • .env files
  • System environment

OAuth 2.0 Configuration

Collections can define OAuth 2.0 authentication with additional parameters:

OAuth 2.0 Authorization Request

OAuth 2.0 Access Token Request

OAuth 2.0 Refresh Token Request

Complete Collection Setup

Directory Structure

collection.bru

environments/dev.bru

environments/prod.bru

auth/folder.bru

users/folder.bru

Best Practices

Use Environments

Create separate environments for dev, staging, and production with appropriate base URLs and credentials.

Secure Secrets

Never commit sensitive data. Use environment variable references like {{SECRET_KEY}} and .env files.

Collection Scripts

Use collection-level scripts for common logic like authentication, logging, and error handling.

Organize Folders

Group related requests in folders with descriptive names and sequence numbers.

Tips

Use collection-level headers for common headers like accept, user-agent, and API versioning.
Set base URLs in environment variables to easily switch between environments.
Use collection-level tests to validate common requirements like response times and status codes.

See Also

Bru Syntax

Complete Bru language syntax reference

Request Format

Request file format specification