> For the complete documentation index, see [llms.txt](https://docs.netmap.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.netmap.dev/security/secrets-management.md).

# Secrets Management

Protect:

* `SECRET_KEY`
* `MASTER_KEY`
* `OIDC_CLIENT_SECRET`
* notification secrets
* SNMP community/profile secrets
* API keys

Production startup requires `SECRET_KEY` and `MASTER_KEY` or their file variants.

Keep secrets with backups. Losing `MASTER_KEY` may make encrypted settings unusable.

## Required Production Secrets

Production startup requires:

* `SECRET_KEY` or `SECRET_KEY_FILE`;
* `MASTER_KEY` or `MASTER_KEY_FILE`.

Generate examples:

```bash
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
```

## Secret Files

File-based secrets are useful with Docker secret managers or host-managed files:

```dotenv
SECRET_KEY_FILE=/run/secrets/netmap_secret_key
MASTER_KEY_FILE=/run/secrets/netmap_master_key
```

The files must be readable by the container process.

## Rotation Caution

Do not rotate `MASTER_KEY` casually. It protects encrypted stored settings. A planned rotation process must account for decrypting and re-encrypting existing values.

API keys are rotated separately by creating a new key and revoking the old one.

## Related Pages

* [API-Key Security](/security/api-key-security.md)
* [Backups](/operations/backups.md)
* [Installation Problems](/troubleshooting/installation-problems.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.netmap.dev/security/secrets-management.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
