Skip to main content

Overview

Request files define individual HTTP, GraphQL, gRPC, or WebSocket requests. Each request is stored as a .bru file within a collection directory.

File Structure

A request file consists of multiple blocks that define different aspects of the request:

Meta Block

The meta block contains request metadata and is required in every request file.

Meta Fields

string
required
Human-readable name for the request
string
required
Request type: http, graphql, grpc, or ws (WebSocket)
number
Sequence number for ordering requests in the collection
array
List of tags for categorizing and filtering requests

HTTP Method Blocks

One of these blocks is required and defines the HTTP method and URL.

GET Request

POST Request

PUT Request

DELETE Request

PATCH Request

Other HTTP Methods

Custom HTTP Method

Method Block Fields

string
required
Request URL with optional variable interpolation
string
Body type: none, json, text, xml, form-urlencoded, multipart-form, graphql, or sparql
string
Authentication mode: none, basic, bearer, digest, awsv4, oauth2, wsse, or apikey
string
Only for http block - custom HTTP method name

Parameters

Query Parameters

Query parameters are appended to the URL with ? and & separators.

Path Parameters

Path parameters replace :paramName placeholders in the URL.

Parameters with Special Characters

Headers

Common Headers

Authentication

Basic Authentication

string
required
Username for basic authentication
string
required
Password for basic authentication

Bearer Token

string
required
Bearer token (typically JWT)

API Key

string
required
Name of the API key parameter
string
required
Value of the API key
string
required
Where to place the key: header or query

Digest Authentication

AWS Signature v4

string
required
AWS access key ID
string
required
AWS secret access key
string
AWS session token (for temporary credentials)
string
required
AWS service name (e.g., execute-api, s3)
string
required
AWS region (e.g., us-east-1)
string
AWS profile name from credentials file

OAuth 2.0

WSSE Authentication

NTLM Authentication

Request Body

JSON Body

Text Body

XML Body

GraphQL Query

GraphQL Variables

SPARQL Query

Form URL Encoded

Multipart Form

Use @file(path) to upload files and @contentType(type) to specify content type.

File Upload

Variables

Pre-Request Variables

Set variables before the request is sent:
Variables prefixed with @ are local and won’t be persisted to the .bru file.

Post-Response Variables

Extract variables from the response:

Response Path Syntax

  • $res.status - HTTP status code
  • $res.body - Response body (parsed as JSON if applicable)
  • $res.body.field - Access nested fields
  • $res.body.array[0] - Access array elements
  • $res.headers.headerName - Access response headers

Assertions

Assertion Operators

  • Exact match: field: value
  • Type check: field: isDefined, field: isNull
  • Numeric: field: > 100, field: < 1000
  • Pattern: field: matches /regex/

Scripts

Pre-Request Script

Execute code before sending the request:

Post-Response Script

Execute code after receiving the response:

Available APIs in Scripts

  • bru.getVar(name) - Get request variable
  • bru.setVar(name, value) - Set request variable
  • bru.getEnvVar(name) - Get environment variable
  • bru.setEnvVar(name, value) - Set environment variable
  • bru.getProcessEnv(name) - Get process environment variable
  • req.getUrl() - Get request URL
  • req.setUrl(url) - Set request URL
  • req.getMethod() - Get HTTP method
  • req.setMethod(method) - Set HTTP method
  • req.getHeader(name) - Get header value
  • req.setHeader(name, value) - Set header
  • req.getBody() - Get request body
  • req.setBody(body) - Set request body
  • res.getStatus() - Get HTTP status code
  • res.getStatusText() - Get status text
  • res.getHeader(name) - Get response header
  • res.getHeaders() - Get all headers
  • res.getBody() - Get parsed response body
  • res.getResponseTime() - Get response time in ms

Tests

Test Assertions

Uses Chai assertion library:
  • expect(value).to.equal(expected)
  • expect(value).to.be.ok
  • expect(value).to.be.a('string')
  • expect(value).to.have.property('field')
  • expect(value).to.match(/regex/)
  • expect(value).to.be.above(number)
  • expect(value).to.be.below(number)

Documentation

The docs block supports Markdown formatting.

Settings

number
default:"0"
Request timeout in milliseconds (0 = no timeout)
boolean
default:"true"
Whether to follow HTTP redirects
number
default:"5"
Maximum number of redirects to follow
boolean
default:"false"
Whether to automatically encode URL parameters

Complete Example

See Also

Bru Syntax

Complete Bru language syntax reference

Collection Format

Collection and environment file formats