# Secrets

> Store API keys and tokens in the workspace vault, grant them to agents, terminals, jobs and MCP servers, and see who used them.

Source: https://docs.ventgris.com/workspace/secrets

Secrets are the keys and tokens the agent and the workspace use: API keys, bot tokens, service account files. A value is typed once, encrypted in the vault of the workspace, and never shown again. What can use a secret is decided by its grants: a grant gives one secret to one grantee (an agent profile, the terminals, a job, an MCP server…) in one mode. The Secrets screen also keeps an access journal of every use.

![Secrets screen with a list of secrets, their grants, last use and age](https://docs.ventgris.com/img/secrets.png)

## Who can do what

| Role | On the Secrets screen |
|---|---|
| `admin` | Add, replace, grant, delete. Every change needs a [step-up](https://docs.ventgris.com/security/sign-in-and-second-factor.md) |
| `editor`, `member`, `viewer` | See the names, the grants, the last use, the age and the journal. No button to change anything |

Nobody, admin included, can read a value back. No screen, command or API returns it.

## Add a secret

1. Click **Add a secret**.
2. Keep **One secret** selected.
3. Fill in the fields:

   | Field | Rule |
   |---|---|
   | **Name** | Letters, digits and underscores, not starting with a digit, up to 128 characters: `FIRECRAWL_API_KEY`. It is also the default variable name when the secret is granted |
   | **Value** | 1 byte to 16 KiB. Masked as you type; the eye button shows it (**Show what I type**). A trailing newline from the clipboard is dropped; a value of several lines (a PEM key) is kept as it is |
   | **Description (optional)** | Up to 300 characters |
   | **Provider (optional)** | Lower case, such as `firecrawl` or `zernio` |

4. Click **Encrypt and store**.
5. Confirm with your second factor when asked.

The screen says "NAME is stored". The value is dropped from the page as soon as the request ends, whether it succeeded or not. A new secret has no grant: nothing can use it until you add one ([Grant a secret](#grant-a-secret)).

If you have not set up a second factor, or cancel the step-up, a banner says "This action needs the second factor. Nothing was changed."

### Paste a .env file

1. Click **Add a secret**, then **Paste a .env**.
2. Paste the content in **Content of the .env file**. One `NAME=value` per line; comments (`#`), `export`, and quoted values (also over several lines) are understood. The screen lists the names it found: "N names found: …".
3. Tick **Replace the value of the names that already exist** if you want to overwrite them. Otherwise existing names are skipped.
4. Click **Encrypt and store**.

The **Result of the paste** lists what was **Created**, **Replaced** and **Skipped**, with the line and the reason of each skipped name (already exists, empty value, value too long or invalid). Pasting several `NAME=value` lines into the single-secret form switches to this mode by itself.

## Grant a secret

1. Click the people icon (**Edit the grants**) on the row of the secret.
2. Click **Add a grant** for each grantee.
3. For each line, pick the **Grantee**, its **Identifier**, the **Mode**, and, for `env` and `file`, the **Variable or file name** (empty means the name of the secret).
4. Click **Save the grants** and confirm with your second factor.

### Grantees

| Grantee | Identifier | Receives the secret |
|---|---|---|
| **Agent** | An enabled agent profile, picked in a list | Every session that runs that profile |
| **Terminal** | Fixed | Every web [terminal](https://docs.ventgris.com/workspace/terminals.md) opened after the grant |
| **Policy** | The name of a session policy | Sessions running under that policy |
| **Job** | The name of a [job](https://docs.ventgris.com/workspace/jobs.md) | Each run of that job |
| **Action** | The name of a [brokered action](https://docs.ventgris.com/agents/brokered-actions.md) | That action, run by the workspace on the agent's behalf |
| **MCP server** | The name of a server on the [Integrations](https://docs.ventgris.com/workspace/integrations.md) screen | The sessions that get that server |
| **Artifact app** | An artifact | An app artifact (apps do not run yet on the service) |
| **Channel** | A channel adapter | The adapter of a [channel](https://docs.ventgris.com/workspace/channels.md), such as a bot token |

You usually do not grant to an MCP server by hand: picking a secret on the Integrations screen creates that grant.

### Modes

| Mode | What the grantee receives |
|---|---|
| `env` | An environment variable, set when the process starts |
| `file` | A read-only file, removed when the process ends |
| `broker` | Nothing. The workspace uses the value itself to run a declared action, behind the guardrails of [Autonomy](https://docs.ventgris.com/workspace/autonomy.md) |
| `proxy` | A placeholder in a sandbox, swapped for the value on the way out |

> [!WARNING]
> A secret that sends, publishes or spends (posting on social networks, sending email, buying credits) belongs in `broker` mode. A key in `env` mode is in the agent's environment: a hijacked session could use it with no guardrail. The vault refuses a secret that is both `broker` for one grantee and `env` or `file` for another.

### Rules the vault checks

| Rule | Message |
|---|---|
| A secret in `broker` mode cannot also be `env` or `file` | "A secret used by the broker cannot also be given to a process (env or file)." |
| Two secrets cannot use the same variable name for the same grantee | "This variable name is taken for this grantee: …" |
| Reserved variable names are refused: `PATH`, `HOME`, `USER`, `LOGNAME`, `SHELL`, `PWD`, `IFS`, `ENV`, `BASH_ENV`, `TERM`, `TMPDIR`, `PROMPT_COMMAND`, and names starting with `LD_`, `DYLD_` or `VG_` | "The server refused these grants: this variable name is reserved: …" |
| One grantee once per secret, at most 100 grants | "The server refused these grants: …" |

A grant can carry an end date, shown as "until DATE" (or "expired"). The grants editor keeps the end date of an existing grant but does not set one.

## When a grant takes effect

A process reads its secrets when it starts. A session turn, a job run or a terminal started after the change gets it; one already running keeps what it had. After **Replace the value**, the screen says "NAME has a new value. Sessions already running keep the old one until they end."

A job or an agent profile may list the secrets it needs. That list is a request: nothing is given until an admin creates the grant here.

## Replace a value (rotation)

1. Click the pencil (**Replace the value**) on the row.
2. Type the new value under **New value for NAME**.
3. Click **Replace** and confirm with your second factor.

The grants stay. The old value cannot be recovered. Replace the key at the provider first, then here.

Each value has a suggested life of 180 days. When it is over, the **Age of the value** column shows **to replace**. The counters above the list show how many secrets are **to replace**, **without grant**, and **unused for 90 days**.

## Delete a secret

Remove all its grants first: a secret with grants shows "This secret still has grants. Remove them first." Then click the bin (**Delete**), confirm "Delete the secret “NAME”? Its value cannot be recovered." and your second factor.

## Read the list

| Column | Content |
|---|---|
| **Name** | The name, the provider, the description, and "added by WHO on DATE" |
| **Mode and grantee** | One tag per grant: mode, grantee, and `→ NAME` when the variable or file name differs. "no grant: nothing can use it" when empty |
| **Last use** | When a process or the broker last received it, or "never" |
| **Age of the value** | Time since it was created or last replaced |

Tags on a name:

| Tag | Meaning |
|---|---|
| **unreadable** | The entry cannot be decrypted. Replace its value |
| **not masked** | The value is shorter than 6 bytes: too short to be recognised and masked in outputs |

## The access journal

Open the **Access journal** tab, or click the activity icon (**See its journal**) on a row to see one secret only. Each line says **When**, which **Secret**, **What** happened, and **Who** (the kind of accessor and its identifier). Never the value.

| What | Meaning |
|---|---|
| created | The secret was added |
| value replaced | A new value was set |
| grants changed | The grants were edited |
| deleted | The secret was removed |
| given to a process | A session, a terminal or a job received it (`env` or `file`) |
| used by the broker | A brokered action used it |
| used by the proxy | A sandbox call used it |
| master key rotated | The whole vault was re-encrypted ("the whole vault") |

**Show older entries** loads the next 100 lines.

## Masking in outputs

The workspace watches what leaves it for the values of the vault, also in their usual encodings (base64, URL encoding, hexadecimal). A value found is replaced by `[secret:NAME]`. Common key shapes that are not in the vault are masked too, as `[secret:generic:KIND]`: private keys (PEM), JWTs, GitHub tokens, AWS access keys, `sk-` keys.

| Output | Treatment |
|---|---|
| Session messages and events, background task output | Values replaced before they are stored or shown |
| Messages sent to a channel | Values replaced |
| Input of a brokered action | Blocked when it holds a secret |
| Publication of an [artifact](https://docs.ventgris.com/workspace/artifacts.md) | Refused when a file holds a secret value |
| Web terminals | Not masked: a person signed in sees what they type |

A replaced or deleted value is still masked for a while, so an old key in a log stays hidden. Values shorter than 6 bytes are not searched.

## Limits

| Limit | Value |
|---|---|
| Value | 1 byte to 16 KiB, no NUL byte |
| Name | 128 characters, `[A-Za-z_][A-Za-z0-9_]*` |
| Grants per secret | 100 |
| Changes to secrets | 30 per minute per person. Above: "Too many changes to secrets. Wait a minute." |
| Step-up | Required for every change; it stays valid 10 minutes |

## How values are protected

Each value is encrypted with its own data key (AES-256-GCM), and the data keys with the master key of the workspace, which never leaves the memory of the Ventgris service on your machine. The vault database is not readable by the agent's Linux users, and backups carry it encrypted. See [Data and backups](https://docs.ventgris.com/security/data-and-backups.md) and [Security overview](https://docs.ventgris.com/security/overview.md).

If the vault cannot open, the screen says "The vault is closed." and no secret is given to anything until it opens again.

> [!AGENT]
> Never ask a person to paste a key into a message, a file or a terminal. Ask an admin to add it on the Secrets screen and grant it to your agent profile (mode `env`) or, for anything that sends, publishes or spends, to the brokered action (mode `broker`). `vg secret list` prints the names of the secrets granted to your session; values are in your environment under their variable names. Never write a value into a file, a commit, an artifact or a message: outputs are scanned and the value becomes `[secret:NAME]`. Check a folder with `vg scan PATH` before you publish or commit it.

## Related

- [Integrations](https://docs.ventgris.com/workspace/integrations.md)
- [Autonomy and guardrails](https://docs.ventgris.com/workspace/autonomy.md)
- [Brokered actions](https://docs.ventgris.com/agents/brokered-actions.md)
- [Sign-in and second factor](https://docs.ventgris.com/security/sign-in-and-second-factor.md)
- [Data and backups](https://docs.ventgris.com/security/data-and-backups.md)
