Configure the Bearer Agent

The Bearer Agent allows you to update the configuration in your code using the following syntax after installing and requiring the @bearer/node-agent package:

secretKey: "your_secret_key",
stripSensitiveData: true, // default
}).then(() => {
console.log("Bearer Initialized")

The Bearer Agent is asynchronous. If initializing at the top level we suggest using theBearer.init({ ... }).then( () => { ... })approach, however you can use async/await where it is supported.

Available Configuration Options

The following is a list of all available configuration options.




Your Bearer Secret Key (required)


When set, the Bearer agent is disabled


When set, Bearer will associate calls made from the app with this environment.


Remove sensitive data before sending it to (defaults to true)


Regular expression used for key name values to strip (see defaults)


Regular expression used for value stripping (see defaults)

For more on using the stripSensitiveData, stripSensitiveKeys, and stripSensitiveRegex configuration properties see Keep your Data Protected.

Setting an application's environment name

Bearer uses your application's environment variable to determine the environments that exist for an application in the Bearer Dashboard. For Node.js, Bearer will use NODE_ENV to determine the environment name.

Alternately, you can use the environment key when initializing the Bearer Agent. Setting environment will take precedence over the NODE_ENV environment name.

If an environment is not explicitly set, either through NODE_ENV or with the environment key, the environment name will default to default.