Overview
Bruno provides several methods for request chaining:bru.runRequest()- Execute requests within your collectionbru.sendRequest()- Send programmatic HTTP requestsbru.runner.setNextRequest()- Control request execution order in collection runs
bru.runRequest()
Execute any request in your collection and retrieve the response directly within your script.
Syntax
showLineNumbers
Parameters
- requestPath: The path to the request relative to the collection root, using folder names as segments and the request name (without the
.bruextension) as the last segment. For a request at the collection root, pass just the request name (e.g."Login"). For a nested request, join the folder names with/(e.g."auth/Login").
Returns
Returns a response object with the following fields:status: HTTP status code (number)statusText: HTTP status text (string)headers: Response headers objectdata: Parsed response body — automatically decoded to a JavaScript object when the response is JSON, otherwise a stringduration: Response time in millisecondssize: Response size in bytesurl: The final request URL
The parsed body lives on
response.data, not response.body. This differs from the res object in post-response and test scripts, where the body is exposed as res.body / res.getBody().Examples
Basic Request Execution
showLineNumbers
bru.sendRequest()
Send a programmatic HTTP request within your script. This allows you to make additional API calls during script execution.
Syntax
showLineNumbers
Parameters
- method: HTTP method (GET, POST, PUT, DELETE, etc.)
- url: The URL to send the request to
- headers: (Optional) Request headers object
- data: (Optional) Request data. Can be a string or object
- timeout: (Optional) Request timeout in milliseconds
- callback: Function to handle the response with signature
(err, res)
Examples
Basic HTTP Request
showLineNumbers
POST Request with Data
showLineNumbers
bru.runner.setNextRequest()
Control the order in which requests are executed during collection runs. This allows you to skip requests or change the execution flow based on conditions.
bru.runner.setNextRequest() works only in post-request scripts or test scripts.Syntax
showLineNumbers
Parameters
- requestName: The name of the next request to execute (string) or
nullto stop execution
How it works
setNextRequestworks with single requests - it executes the current request first, then jumps to the specified request- It skips all requests between the current one and the target request
- The target request must exist in the collection and be specified by its exact name
- For requests inside folders: Use just the request name (e.g., “request-name”), not the full path
Examples
Conditional Request Execution
showLineNumbers
- Use
bru.runRequest()for requests within your collection (faster, uses existing configuration) - Use
bru.sendRequest()for external APIs or when you need custom request configuration - Avoid nested loops that could cause infinite request chains