Secrets

Secrets let you store sensitive values — API keys, tokens, passwords — in the Admin UI and reference them anywhere in your configuration with ${KEY} syntax. No more hardcoding credentials or juggling environment variables across deployments.

Creating a secret

Open the Admin UI, click Secrets in the sidebar, then + New Secret.

Secrets list showing one existing secret

Fill in the form:

New Secret dialog with fields for name, key, value, and description
FieldWhat to enterExample
NameA human-readable labelOpenAI API Key
Environment Variable KeyThe key you’ll reference with ${...}. Must be UPPER_SNAKE_CASE.OPENAI_API_KEY
ValueThe actual sensitive value. Once saved, it’s never shown again.sk-...
DescriptionOptional note for yourselfProduction key for GPT-4o

Click Save. The secret is ready to use immediately.

Secret values are write-only. After saving, the value is never displayed again — not in the UI, not in the API. When editing a secret, leave the value field empty to keep the current value, or enter a new one to replace it.

Using secrets in your configuration

Once created, reference a secret anywhere by wrapping its key in ${...}. For example, when configuring a backend:

Memory provider using ${POSTGRES_PASSWORD} in the connection string

Here the connection string uses ${POSTGRES_PASSWORD} — Magec replaces it with the actual secret value at runtime.

Where you can use ${KEY}

Secrets work in every resource field:

ResourceExample fieldExample value
BackendsAPI Key${OPENAI_API_KEY}
BackendsBase URL${OPENAI_BASE_URL:-https://api.openai.com/v1}
MemoryConnection Stringredis://${REDIS_PASSWORD}@redis:6379
MCP ServersEnvironmentGITHUB_TOKEN: ${GITHUB_TOKEN}
ClientsToken${TELEGRAM_BOT_TOKEN}

The ${VAR:-default} syntax is also supported — if the variable is unset or empty, the default value after :- is used instead.

How it works under the hood

When Magec starts, all secrets are injected as environment variables. Then every ${VAR} reference in the store is expanded. This means secrets and regular environment variables (from Docker, Kubernetes, systemd) all work the same way.

If you need to understand the expansion pipeline, encryption details, external env var compatibility, or recovery procedures, see Advanced Secrets.

Encryption

When an admin password is configured, all secret values are encrypted on disk using AES-256-GCM. Without an admin password, secrets are stored in plain text — a warning is logged to remind you to enable it.

See Advanced Secrets — Encryption at rest for the full technical details.