# Secrets

Source: https://modulify.ai/docs/data/secrets

Store API keys and configuration as environment variables your site reads at runtime.

A secret is one named value your site reads from its environment, such as a payment provider key, a mail service token or a feature flag. You store it in the Secrets tab and read it in code as `process.env.KEY_NAME`.

Secrets exist so credentials never live in your source files. A key pasted into a component ends up in the GitHub repository behind your project. A key stored here is encrypted at rest and handed to the machine that runs your site instead.

## Open the Secrets tab

Secrets lives behind **More** in the editor tab strip. Click **More**, then **Secrets** in the list on the left. Its address is `/dashboard/projects/<your-project>/secrets`, so the link is shareable and survives a reload.

**Secrets** is the first entry in that list, so when you open a project **More** lands on it until you have used another of the thirteen tabs, and from then on it reopens whichever you used last. [Tabs and visibility](https://modulify.ai/docs/editor/tabs-and-visibility) covers the rest of the strip.

Before you add anything the panel reads `No secrets` with `Add one, or drop a .env file.`

## Add a secret

Click **Add secret**, in the middle of the panel while it is empty or at the right end of the list header once you have secrets. It opens a dialog with the same fields described below, and stays open after each save so you can add several secrets in one sitting instead of reopening it each time.

### Type the name

The `KEY` field takes the variable name. Use letters, digits and underscores, starting with a letter or an underscore, the way environment variables are normally written: `STRIPE_SECRET_KEY`, `RESEND_API_KEY`, `NEXT_PUBLIC_SITE_URL`. Anything else in the name is replaced with underscores when it saves, and digits at the start of it are dropped.

You can also paste a whole `KEY=value` line into this field. The name lands in `KEY` and the value lands in `value`. Pasting several lines adds a row for each one, see **Paste several at once** below.

### Type the value

The `value` field takes the value itself. A value is stored up to 10,000 characters and a name up to 255 characters.

### Choose Secret or Public

The lock icon next to the value opens a two entry menu: **Secret** and **Public**. Secret is the default.

### Add it

Press **Add secret**, or press Enter in either field. You get a **Secret saved** toast, the dialog stays open and both fields clear so you can add the next one, and the list scrolls to the new row and highlights it briefly.

Pressing **Add secret** with an empty name, or with a name the platform reserves, saves nothing and outlines the field in red:

- An empty name reads `Enter a key to add a secret.`
- A reserved name reads `This key is reserved by the system and cannot be used.`

A name you already have is allowed and replaces that secret. The field is outlined in amber and reads `A secret with this key exists. Adding replaces its value.`, and pressing **Add secret** asks first. **Replace <KEY>?** reads `<KEY> already exists. Adding it replaces its current value, and the old value cannot be recovered.` **Replace** saves the new value over the old one, with the Secret or Public choice from the dialog, and **Cancel** leaves the dialog as it was.

### Secret or Public

The choice controls how the value is stored, not who can see it in a browser.

| Choice | Icon | How it is stored |
|---|---|---|
| **Secret** | Lock | Encrypted at rest with AES-256-GCM, decrypted only when you reveal it or when it is handed to your site |
| **Public** | Globe | Stored as plain text |

Both kinds are injected into your site's environment the same way and both are readable from your server code as `process.env`. Neither is automatically sent to the browser. Whether a value reaches the browser is decided by the name: a Next.js project exposes a variable to client code only when its name starts with `NEXT_PUBLIC_`.

> **Warning**
>
> Never name a real credential with the `NEXT_PUBLIC_` prefix. That prefix is what puts the value into the JavaScript bundle your visitors download, whichever storage option you picked.

## Paste several at once

Open **Add secret**, then copy the contents of a `.env` file and paste them into the `KEY` field. The first line fills the `KEY` and `value` fields, and every further line becomes its own row underneath. Once there are two rows or more, every row, the first one included, has a name, a value, its own Secret or Public choice and an x that removes it. Removing the first row moves the next one up. The rows are editable before anything is saved. Pasting into the `value` field does the same when the clipboard holds more than one line. A single line pasted there is treated as an ordinary value, since a value can legitimately contain an equals sign.

**Add another**, the full width button under the rows, adds one empty row by hand, for anyone who would rather type several secrets than paste them. Press it as many times as you need; each press adds one more row.

Below it, the main button relabels itself **Add 3 secrets** and saves them all in one go, and **Clear** discards the extra rows and keeps whatever is in the first one. Enter saves the same set. If the first row is left empty, only the rows below it are saved, and a first row with a value but no name reads `A key is required.`

Pressing the button checks every row first and saves nothing while one fails:

- An empty name reads `A key is required.`
- A name that another row already uses reads `This key appears more than once below.`
- A reserved name reads the same as it does for a single one.

A row with a name you already have shows the same amber note as a single one, and the button asks once for all of them. **Replace 3 secrets?** names them, for example `API_KEY, STRIPE_KEY and DB_URL already exist. Adding them replaces their current values, and the old values cannot be recovered.` Past five names the list ends with a count such as `and 2 more`.

When many rows are pasted, the rows scroll on their own so the first row and the buttons stay in view.

Each row is saved with its own Secret or Public choice, and a row added by pasting or with **Add another** starts as **Secret**. Pasting the same name twice keeps the later value, and pasting a name the first row already holds updates that row's value instead of adding a duplicate.

Text that is not a set of `KEY=value` lines is pasted as typed, so a name copied on its own still lands in `KEY` unchanged.

## What happens when you save

Saving one secret triggers three things.

**Your preview updates straight away.** The whole set of variables is pushed to the machine running your preview, its environment is replaced with the new set, and the dev server restarts if anything actually changed. The API logs stream records a line like `Runtime environment synced (12 active)`. A variable you deleted is removed from the environment in the same push.

**Your published site does not change.** The live machines were given their environment when you last published, so they keep serving the old value. Publish again for a new or changed secret to take effect. The values are read once per publish and go to both the build and the running server, so a value read at build time is baked into the output of that build.

**Everyone else with the tab open sees it.** The Secrets list refreshes on its own for every other person who has this tab open on the site, whether the change came from the Secrets tab, from the AI in chat or from a connected MCP client. The refresh hides any values they had revealed, so they click the eye icon again to read one.

> **Note**
>
> Because values are read at build time as well as runtime, a tracking id or a public URL only starts working on the next publish. [Publish a site](https://modulify.ai/docs/publish/publish-a-site) covers that step.

## Read a value back

Values are not write-only. Every row shows eight dots until you click the eye icon on it, which fetches the value and shows it.

For a **Public** row the value is already in the list, so the eye reveals it with no round trip. For a **Secret** row the eye decrypts it on the server first, and the icon spins while it does. Clicking the dots themselves opens the value for editing, which reveals it too.

Each row also has two copy icons, one on the name and one on the value. Copying a hidden value reveals it first.

> **Warning**
>
> Every accepted member of the workspace who is an Editor on this site can open this tab, see every name and read a **Public** value, which is already in the list. A member whose [role on this site](https://modulify.ai/docs/reference/members-and-roles#roles-on-a-single-site) is Content editor or Viewer cannot open it: **More** is disabled for them with `Your role on this site does not include this.` Reading a **Secret** value back needs the **Delete projects** permission, and so does everything that reveals one first: the eye icon, the copy icon on the value, opening the value to edit it, renaming the row, and **Copy secrets** or **Download secrets** whenever the rows they would export include a **Secret** one. Without the permission those controls are disabled with a tooltip rather than missing, while **Copy secrets** and **Download secrets** keep working when every row they would export is **Public**, since those values are already in the list. See [Members and roles](https://modulify.ai/docs/reference/members-and-roles).

## Edit and rename

Both fields on a row edit in place. Click the name or the value, change it, then press Enter or click away to save. Escape cancels and puts the old text back.

Editing a value keeps the row's existing Secret or Public choice. To flip a row between the two, add it again under the same name with the other choice in **Add secret**, which replaces it after the **Replace** question described above.

> **Note**
>
> Renaming an encrypted secret reveals its value first, so the value carries over to the new name. If the reveal is refused or cancelled, the rename is abandoned and the key is left as it was.

## Delete

The trash icon on a row deletes it. You are asked to confirm with **Delete this secret?** and the dialog warns that this permanently deletes the secret and removes it from your site, and that it cannot be undone.

Deleting removes the variable from the preview environment on the next sync. Your published site keeps it until you publish again, so a site that depends on the value keeps working live and breaks on the next build.

To delete several at once, tick the checkbox on each row. The three dots menu in the list header then holds **Copy secrets**, **Download secrets** and **Delete secrets**, each acting on the ticked rows. The checkbox in the header ticks every row the list is showing, including managed rows while **Managed secrets** is open, or clears the selection when they are all ticked already. While a search is active only the rows that match it count: the header checkbox ticks just those, and **Copy secrets**, **Download secrets** and **Delete secrets** leave out any ticked row the search hides. Escape clears the selection.

Ticking a managed row into the selection does not stop **Delete secrets**: it deletes the rest and skips the managed ones, and the confirmation names how many are skipped before you commit. If every ticked row is managed, **Delete secrets** is disabled with a tooltip explaining managed secrets cannot be deleted, so there is nothing to confirm.

## Copy and export

With nothing ticked, the three dots menu next to **Add secret** in the list header holds **Import secrets** and two export entries:

- **Copy secrets** puts every row on your clipboard as `KEY=value` lines, and you get a **Copied** toast.
- **Download secrets** saves the same lines as a file named `secrets-2026-08-25.env`, dated the day you export.

With rows ticked, the same two entries in that menu act on the selection instead of everything. Either action reveals any hidden values it needs first.

Managed keys, and any other row under a reserved name, are left out of both.

> **Careful**
>
> An exported `.env` file is plain text with every one of your production credentials in it. Do not put it in the project folder, do not attach it to chat, and delete it when you are done with it.

## Import a .env file

Drag a `.env` file anywhere onto the panel, or onto the open **Add secret** dialog. An overlay reads `Drop to import secrets`, and on drop the file's lines open in the **Add secret** dialog as rows you can edit before saving. The same import runs from **Import secrets** in the three dots menu next to **Add secret** in the list header, which opens a file picker instead. That menu is there once the project has at least one secret. A line under the list reminds you of both: `Drop a .env file here, or import one from the dots menu, to add several at once.`

The parser reads `KEY=value` lines, ignores blank lines and `#` comments, accepts a leading `export `, and strips one layer of matching single or double quotes from the value. It stops at 200 entries.

- A file over 1 MB is refused with `Choose a .env file under 1 MB!`
- A file with a line that has no `=`, or a name that is not a valid variable name, imports nothing and reads `No secrets found`, `Expected KEY=value lines, one per secret!`
- A reserved name in the file becomes a row that reads `This key is reserved by the system and cannot be used.` once you press the button, and has to be removed before the rows can be saved.

Imported rows are saved the same way as pasted ones: when you press the button, with the Secret or Public choice you picked in the dialog, and a name you already have asks before its value is replaced.

## Reserved names

Some names belong to the platform and are refused.

```markdown
DATABASE_URL
DATABASE_TOKEN
CDN_URL
CDN_PRIVATE_KEY
EMAIL_URL
EMAIL_PRIVATE_KEY
GITHUB_TOKEN
GITHUB_REPO_URL
WS_TOKEN
PROJECT_ID
CLOUDFLARE_CDN_DOMAIN
PREVIEW_BYPASS_TOKEN
MODULIFY_APP_URL
MODULIFY_API_URL
MODULIFY_ANALYTICS_URL
MODULIFY_ANALYTICS_KEY
MODULIFY_AI_URL
MODULIFY_AI_KEY
MODULIFY_MESSAGES_URL
MODULIFY_MESSAGES_KEY
MODULIFY_PAYMENTS_URL
MODULIFY_PAYMENTS_KEY
```

Names beginning with `__MODULIFY_` belong to the platform too: the ones it uses are refused, and any other one saves but is removed before a published site starts, so it only ever reaches the preview. Names beginning with `ANTHROPIC_` or `CLAUDE_CODE_` are also reserved: those save without an error but are stripped before the set is handed to your site, so a value stored under one never reaches your code.

### Managed secrets

Some reserved names appear in your list anyway, with a **Managed** badge. Hovering it reads "This secret is managed by Modulify and cannot be edited or removed."

They are hidden at first, so the list opens on the secrets you added yourself. A **Managed secrets** row at the bottom of the list counts them, for example **Managed secrets (6)**, and clicking it shows them under it. Clicking it again hides them. They are hidden again each time you open the tab, on the web and in the mobile app alike. A search filters them too, and the count on the row then shows how many of them match.

`DATABASE_URL` and `DATABASE_TOKEN` are the ones you will meet first. They appear together when your project gets a database: `DATABASE_URL` holds the address of the database and `DATABASE_TOKEN` the token your site sends with each request. `CDN_URL` and `CDN_PRIVATE_KEY` appear for file storage the same way, and `EMAIL_URL` and `EMAIL_PRIVATE_KEY` for the email the site sends, which [Emails](https://modulify.ai/docs/built-in/emails) covers. Those two appear once the preview has started or the site has been published while sending is on, which it is unless somebody turned it off. `MODULIFY_ANALYTICS_URL` and `MODULIFY_ANALYTICS_KEY` hold the address and the key of the [analytics API](https://modulify.ai/docs/grow/analytics-http-api). They appear once the preview has started or the site has been published, or as soon as the key is copied from the Analytics tab. If you had created a variable with either of those two names yourself, it is replaced by the managed value and locked. `MODULIFY_AI_URL` and `MODULIFY_AI_KEY` hold the address and the key of the site's [AI](https://modulify.ai/docs/built-in/ai). They appear once the preview has started or the site has been published, and they replace and lock a variable of yours with either name the same way. `MODULIFY_MESSAGES_URL` and `MODULIFY_MESSAGES_KEY` hold the address and the key your site's code sends [texts](https://modulify.ai/docs/built-in/messages) with, and appear the same way. `MODULIFY_PAYMENTS_URL` and `MODULIFY_PAYMENTS_KEY` hold the address and the key your site's code creates [payment links](https://modulify.ai/docs/built-in/payments) with. They appear once payments are on for the site and the preview has started or the site has been published, and a site moved to another workspace gets a new key. You can reveal, copy and tick the checkbox on a managed row, but you cannot rename it, change it or delete it, and neither can the AI. It lives and dies with the thing that created it.

A site that already had its own `EMAIL_URL` or `EMAIL_PRIVATE_KEY` secret before those names were reserved keeps it as an ordinary row without the badge. Modulify never replaces it, so it keeps reaching your site, and the site cannot send email through Modulify until that row is renamed or deleted. You and the AI can still change its value and delete it, but you cannot create a new secret with either name or rename another row to one.

Its checkbox works the same as any other row's, and **select all** in the header ticks the managed rows too while they are shown, but no bulk action uses a managed row. **Copy secrets** and **Download secrets** leave it out, as [Copy and export](https://modulify.ai/docs/data/secrets#copy-and-export) says, and **Delete secrets** skips it, as [Delete](https://modulify.ai/docs/data/secrets#delete) says.

Managed is about ownership, not secrecy. The eye icon works on these rows too, so the database credentials, the private storage key, the analytics API key, the AI key, the texting key and the payments key read out in full for anyone with the **Delete projects** permission, exactly like a key you added yourself. [Site databases](https://modulify.ai/docs/data/databases) covers what is inside each of the database values.

Managed rows always sit at the bottom of the list, under **Managed secrets**, in alphabetical order. Your own rows come first: public rows, then encrypted ones, alphabetically within each band. The list header counts every secret, managed ones included, reading `12 secrets`, or `3 selected` once you tick something.

## Find a secret

Once a project holds 8 or more secrets, a search box and a sort dropdown appear above the list. Type part of a name in the search box to filter the rows down to matches. The search only matches the key name, not the value. Clear it with the x inside the box, or delete what you typed, to bring back every row.

A search with no matches reads `No matches` with `Try a different keyword.` instead of an empty list.

The sort dropdown next to it holds three choices: **Name**, **Newest first** and **Oldest first**. **Name** is the default: public rows first, then encrypted ones, alphabetically within each band, exactly as the list is ordered below the threshold. **Newest first** and **Oldest first** order by when a secret was added instead, mixing public and encrypted rows together. Whichever sort you pick, managed secrets stay under **Managed secrets** at the bottom of the list.

## What the AI can do

The AI working in chat can list your key names, create keys, set values, rename keys and delete keys. It cannot read an existing value back: no chat tool reveals one, so a value you saved is a name to it and nothing more.

Renaming from chat keeps the value where it is without reading it, and chat then changes the code that reads the old name. Managed secrets cannot be renamed, no secret can take a reserved name, and an encrypted secret cannot be renamed to a `NEXT_PUBLIC_` name from chat, because that name puts its value in your site's browser code. Rename that one in the Secrets tab, where the value is shown first.

That shapes how it works. Ask for a Stripe checkout and it writes the code against `process.env.STRIPE_SECRET_KEY`, then opens the **Add secrets** dialog of this tab with `STRIPE_SECRET_KEY` filled in as the name, so you paste the value there and save it without it passing through chat. The dialog opens on its own for the person who asked, and a card in the chat opens it again. On the mobile app, that card's **Open** opens this panel and its add sheet with the names filled in. When the message came from an AI client or the API with an access token, it creates `STRIPE_SECRET_KEY` with the literal placeholder value `REPLACE_ME` instead and tells you to open the Secrets tab and replace it. It will not ask you to paste the real key into chat, and it will not create a `.env` file in your project. [Writing prompts](https://modulify.ai/docs/build/writing-prompts) covers that convention.

The same actions are available over MCP as `list_secrets`, `set_secret`, `set_secrets` for a whole `.env` at once, `rename_secret` and `delete_secret`. Reading a value back needs `get_secret` or `get_all_secrets`, which sit behind the separate `credentials:reveal` scope because they hand the client the real value in plain text, and which need the **Delete projects** permission like the eye icon.

So an AI can read a value, in exactly one place: a connected client, on a token you gave that scope to yourself. It is unticked when the token form opens, and leaving it unticked means the tools are never even registered for that client. `get_all_secrets` leaves the managed rows out, the way **Copy secrets** does, so `DATABASE_URL`, `DATABASE_TOKEN`, the storage keys, the email keys and the analytics keys come back only from `get_secret`, one at a time. See [MCP tools](https://modulify.ai/docs/mcp/tools#secrets) and [Tokens and scopes](https://modulify.ai/docs/mcp/tokens-and-scopes).

## Secrets and the CMS are different things

Both hold data your site reads, and it is worth being clear about which one a value belongs in.

| | Secrets | [The CMS](https://modulify.ai/docs/data/cms) |
|---|---|---|
| Holds | One value per name, for the whole site | Rows in tables, as many as you like |
| For | Credentials, endpoints, configuration | Content: posts, products, team members |
| Reached from code as | `process.env.KEY_NAME` | A database query |
| Changes take effect | In the preview at once, live on the next publish | Live at once |
| Who edits it | Editors on the site, in this tab | Editors and Content editors on the site, in the CMS tab |

The rule of thumb: if the site would break without it and you would not show it to a visitor, it is a secret. If it is something the site displays and you expect to add more of, it belongs in the CMS.

## Limits

A project holds up to **200 secrets** of its own. [Managed secrets](https://modulify.ai/docs/data/secrets#managed-secrets) do not count toward that cap. At the cap the **Add secret** button itself is disabled, with a tooltip that reads `Limit reached (200). Contact support for more.` Saving several rows at once, pasted or imported, that would take you past the cap is refused before anything is written, with `This would exceed the 200 secrets per project limit. Remove some secrets before adding more!`

Names are capped at 255 characters and values at 10,000 characters.

## Secrets when a project is copied

Duplicating a project copies your secrets with their real values, since the copy is your own. Cloning a shared project copies your key names across but not your values, unless the owner turned on **Include environment variables** in the Share panel. Without it every copied key arrives holding the literal text `VALUE_HERE` for the new owner to fill in. Managed and reserved keys are never copied. [Sharing and cloning](https://modulify.ai/docs/projects/sharing-and-cloning) covers those toggles.

## FAQ

### Do I need to publish for a secret to take effect?

For your live site, yes. The preview picks up a change within seconds, but the published machines were handed their environment at publish time and keep the old value until you publish again.

### Can I see a value after saving it?

Yes. Click the eye icon on the row. An encrypted value needs the **Delete projects** permission and is decrypted on the server for that request.

### Can the AI read my API keys?

Not the one in chat. It lists the names, creates keys and deletes them, and no chat tool returns a stored value. A connected AI client can, through `get_secret` or `get_all_secrets`, but only on a token you gave the `credentials:reveal` scope to, which is unticked by default.

### Why are DATABASE_URL and DATABASE_TOKEN locked?

They are created and owned by your site database, so their values have to match the database that actually exists. Delete the site and they go with it. Locked stops them being edited or deleted, not read: the eye icon reveals each one like any other row.

### Should I put a `.env` file in my project?

No. A `.env` in the project directory is committed to the GitHub repository behind your site, which leaks every value in it. That is the reason this tab exists.

## Next

- [Site databases](https://modulify.ai/docs/data/databases) explains the managed `DATABASE_URL` and `DATABASE_TOKEN` secrets.
- [Scheduled jobs](https://modulify.ai/docs/automations/scheduled-jobs) can point a request header at a key from this tab.
- [Custom code and trackers](https://modulify.ai/docs/grow/custom-code-and-trackers) is the common case for a `NEXT_PUBLIC_` value.
- [Publish a site](https://modulify.ai/docs/publish/publish-a-site) is what carries a changed secret to your live site.