# Secret vs. variable: what is the difference?

> A secret is a value that must stay hidden, such as an API key, while a variable is configuration that is safe to show, such as a region name.

A secret is a value that gives access to something and must stay hidden, such as an API key, a token or a password. A variable is configuration that changes how a program behaves and is safe to show, such as a region name or a log level. Both usually reach a program the same way, as named values in its environment, which is why they are easy to mix up.

## Why it matters

The two need different handling. If you treat a secret as a variable, it is shown to people and agents who should not have it. If you treat every setting as a secret, ordinary configuration becomes harder to read and review.

Some values look like configuration and carry a credential. A database URL can contain a password. A webhook URL can contain a token. A simple test helps: if someone who holds the value could use it to get access, it is a secret.

## How Guardry does it

In Guardry an environment holds entries, and each entry is a secret or a variable. Names look like environment variables, for example `STRIPE_KEY`.

| | Secret | Variable |
| --- | --- | --- |
| Value | Hidden | Visible |
| Viewer role | Cannot reveal the value | Sees the value |
| Agent credential that covers the environment | Reads the value only if its permissions allow it | Sees the value, without approval |

An agent whose credential may create entries can add a variable. The value comes from standard input:

```sh
printf %s eu-west-1 | guardry secrets create AWS_REGION --stdin --kind variable
```

## Which one to choose

- Choose a secret for API keys, tokens, passwords, TOTP seeds, and anything that contains one of them.
- Choose a variable for a value you would be comfortable showing to every teammate and every agent in that environment.
- When you are unsure, choose a secret.

## Questions

### Can an agent read a variable without approval?

Yes. Variables are visible to every agent credential that covers their environment, without approval. Anything sensitive should be a secret.

### Is a database URL a secret or a variable?

If it contains a password or a token, it is a secret. If it is only a host name and a port, it can be a variable.

### What can a viewer see?

A viewer sees names, descriptions, variable values and the audit log. A viewer cannot reveal a secret.

---

Source: https://guardry.ai/answers/secret-vs-variable/ · Updated 2026-11-27 · Guardry for language models: https://guardry.ai/llms.txt
