# Secrets

Source: https://openpanel.sh/docs/variables/secrets

Variables whose value is sealed when you save it, never shown again, and given only to your service's containers.

A secret is a [variable](/docs/variables) whose value nobody reads back. You set it, a deploy hands it to your service, and from then on it shows as a secret with no value, in the console, the CLI, the API and MCP alike.

## Set a secret [#set-a-secret]

<Tabs items={["Console","CLI","API"]}>
<Tab value="Console">
On the service's **Variables** tab, or the project's **Shared variables** page, click **Add variable**, give its **Name** and **Value**, tick **Secret**, and click **Add variable**. To replace a secret's value, click **Set a new value** on its row; the old value cannot be shown.
</Tab>

<Tab value="CLI">
```sh
printf %s "$STRIPE_KEY" | openpanel env set STRIPE_KEY --secret --project shop --service api
```

With a name and no `=value`, the CLI reads the value from standard input, so it never appears in your shell's history or in the list of running processes. `NAME=value --secret` works too.
</Tab>

<Tab value="API">
```sh
curl -X PUT "https://openpanel.sh/api/v1/projects/$PROJECT_ID/variables/STRIPE_KEY" \
  -H "Authorization: Bearer $OPENPANEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "value": "'"$STRIPE_KEY"'", "secret": true, "serviceId": "'"$SERVICE_ID"'" }'
```

The answer has `"secret": true` and `"value": null`.
</Tab>
</Tabs>

A secret can be set on a project, an environment or a service, like any variable, and the narrowest scope wins the same way.

## What happens to the value [#what-happens-to-the-value]

1. **Sealed when you save it.** OpenPanel seals the value with AES-256-GCM under its own key before it is stored, bound to that variable, so a sealed value copied elsewhere does not open. See [Secrets and encryption](/docs/security/secrets).
2. **Never read back.** Lists show the name, `"secret": true` and no value. Nobody can read it back, whatever their role.
3. **Sealed again for one server.** At a deploy, the value is sealed for OpenPanel's gateway alone, bound to the server that runs the service and to that version of its state. Only the gateway can open it.
4. **Sent to the agent over its encrypted connection.** The gateway hands the value to the [agent](/docs/servers/agent) on that server, which gives it to the container as an environment variable.

A deployment's record never holds a secret's value: its copy of the variables names the secret, not what it contains.

<Callout type="warn" title="On your server, a secret is an environment variable">
Inside the container, and to anyone with root on the server, a secret is an ordinary environment variable. Sealing protects it in OpenPanel's database and on the way to your server, not from people who control the server.
</Callout>

## Change or remove a secret [#change-or-remove-a-secret]

Set it again with a new value, or remove it with `openpanel env unset`, then deploy. Until the deploy, the service may run with either the old value or the new one: a secret's value is read again whenever its server's state is written, for example when another service on that server deploys.

To turn a secret back into a plain variable, set the name again without `--secret` (`"secret": false`). The new value replaces the sealed one.

## Values built from a secret [#values-built-from-a-secret]

A plain variable that [refers](/docs/variables/references) to a secret, such as `PAYMENT_URL=https://${{api.STRIPE_KEY}}@pay.example.com`, becomes a secret itself when the service is deployed: its worked-out value is sealed and sent the same way. Lists still show such a variable as you typed it, with the reference and not the secret's value.

## Who can do what [#who-can-do-what]

- **Set, replace and remove** a secret: members with deploy access to the project.
- **Read its value**: nobody, through the CLI, the API or MCP. Only your service's containers receive it.
- **The [audit log](/docs/monitoring/audit-log)** records each change by name, never the value.