1. Secrets
  2. Secrets

Storing Secrets

In various surfaces in Mage, you may be asked to input config for certain integrations such as cloud databases or services. In these cases, you may need to input a password or an api key, but you don’t want it to be shown in plain text. To get around this issue, we created a way to store your secrets in the Mage database.

To manage your secrets, you’ll want to go to the edit page for a pipeline. In the sidekick, you should see a Secrets tab. To create a secret, press the New button on this tab. Input a name for the secret and the value of the secret, and press Enter or Return to save.

Create Secrets

The secrets can be shared across the project that they are created in.


Your secrets are encrypted before being stored into the Mage database. The encryption key will be stored in the Mage data folder which by default will be created at ~/.mage_data. If you need more secure encryption, we recommend using a secrets manager.

Using Secrets

To use a secret that you created, you will need to specify the secret in the config. You can use the following syntax to have Mage inject the secret when reading from the config:

field_name: "{{ mage_secret_var('your_secret_name') }}"

Using Secrets

You can also fetch the secret value in a Mage code block by importing a helper method:

from mage_ai.data_preparation.shared.secrets import get_secret_value