Set Pre Request and Post Response variables on a request’s Vars tab.
Request variables are scoped to a specific request. Use them for values that belong to that request only, not the whole collection or environment.The Vars tab has two sections:
Pre Request runs before the request is sent.
Post Response runs after the response is received.
Request variables are scoped to the request and cannot be accessed outside of it. This keeps values separated between requests.
Creating a Pre Request variable
Open the request and go to the Vars tab.
In Pre Request Vars, add the variable name, value, and an optional description.
Save your changes.
You can use strings, numbers, or any valid JavaScript literal.
Using a request variable
Use the {{varName}} syntax to reference a Pre Request variable in the URL, headers, body, or other request fields.
Access request variables in scripts
Use bru.getRequestVar() to read a Pre Request variable in scripts:
let source = bru.getRequestVar("source");let destination = bru.getRequestVar("destination");
bru.getRequestVar() only reads Pre Request Vars defined on the current request’s own Vars tab. It does not read variables defined on a folder or collection.To read a variable defined at any other scope (global, collection, environment, folder, or runtime), use bru.getVar("name"), which walks the full precedence chain described in the Variables overview. For a scope-specific getter, use bru.getCollectionVar(), bru.getFolderVar(), or bru.getEnvVar().
Post Response variables
In Vars → Post Response, you can write any valid JavaScript expression. The res object is available, so you can parse the response object and set variables declaratively instead of writing a full script.For parsing the response body, use response query (for example res('customer.address.city')). Response variables will be available to see in Runtime variables section.
Deleting a request variable
Request variables are stored in the request file. To delete one, remove the row from the Vars tab:
Open the request.
Go to the Vars tab.
Click the delete icon on the variable row (Pre Request or Post Response).
Save the request.
bru.deleteVar() and bru.deleteAllVars() remove runtime variables only. They do not delete request variables defined on the Vars tab.