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
Themeta 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 sparqlstring
Authentication mode:
none, basic, bearer, digest, awsv4, oauth2, wsse, or apikeystring
Only for
http block - custom HTTP method nameParameters
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 queryDigest 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
- Client Credentials
- Password Grant
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: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 API
bru API
bru.getVar(name)- Get request variablebru.setVar(name, value)- Set request variablebru.getEnvVar(name)- Get environment variablebru.setEnvVar(name, value)- Set environment variablebru.getProcessEnv(name)- Get process environment variable
req API (Pre-Request)
req API (Pre-Request)
req.getUrl()- Get request URLreq.setUrl(url)- Set request URLreq.getMethod()- Get HTTP methodreq.setMethod(method)- Set HTTP methodreq.getHeader(name)- Get header valuereq.setHeader(name, value)- Set headerreq.getBody()- Get request bodyreq.setBody(body)- Set request body
res API (Post-Response)
res API (Post-Response)
res.getStatus()- Get HTTP status coderes.getStatusText()- Get status textres.getHeader(name)- Get response headerres.getHeaders()- Get all headersres.getBody()- Get parsed response bodyres.getResponseTime()- Get response time in ms
Tests
Test Assertions
Uses Chai assertion library:expect(value).to.equal(expected)expect(value).to.be.okexpect(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