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>
.
If you have a secret named dbCredentials with a key username, you can reference it as: $secrets.dbCredentials.username
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: Using AWS Secrets Manager secrets in authentication
const apiKey = bru.getSecretVar('aws-secrets.api-key');
req.setHeader('Authorization', 'Bearer ' + apiKey);
This approach keeps your sensitive data secure while allowing you to leverage AWS Secrets Manager secrets in your API automation scripts.