> ## Documentation Index
> Fetch the complete documentation index at: https://bruno-a6972042-mintlify-c74cb75a.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Using secrets in Request Fields

Secrets are accessed in the same way as collection and environment variables in headers, query params, body, and auth fields.

<Tip>
  **v4 syntax change:**

  * The recommended syntax is now `{{secret-name.key-name}}` (e.g. `{{dbCredentials.password}}`).

  * The old `{{$secrets.secret-name.key-name}}` syntax still works in v4 but is deprecated and it is shown with an underline in the editor and will be removed in the next major release.
</Tip>

**Recommended syntax (v4+):**

```
{{<secret-name>.<key-name>}}
```

For example, if you have a secret named `dbCredentials` with a key `password`, reference it as `{{dbCredentials.password}}`.

**Legacy syntax (deprecated):**

```
{{$secrets.<secret-name>.<key-name>}}
```

For example: `{{$secrets.dbCredentials.password}}`

## Using Secrets in Scripts

You can also access secrets from within Pre-request and Post-request scripts using the `bru.getSecretVar()` function.

```javascript theme={null}
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.

## Using Secrets with Bruno CLI

To learn more about using secrets with Bruno CLI, please refer to [CLI Documentation](/bru-cli/secret-managers).
