Using secretsPremium

Using Secrets in Request Fields
Secrets are accessed in the same way as collection and environment variables. The secrets can be accessed in headers, query, body, auth input fields similar to collection and environment variables.
Secrets need to be prefixed with $secrets
followed by the secret name
and then the key name
, all separated by periods.
Pattern: $secrets
.<secret-name>
.<key-name>
.
Using Secrets in Scripts
You can also access secrets from within Pre-request and Post-request scripts using the bru.getSecretVar()
function.
const secretValue = bru.getSecretVar('<secret-name>.<key-name>');
console.log(secretValue); // This will log the value of your secret
// Example
const apiKey = bru.getSecretVar('payment-service.api-key');
req.setHeaders('x-api-key: ' + apiKey);
This approach keeps your sensitive data secure while allowing you to leverage it in your API automation scripts.