Secrets
Store API keys, passwords and tokens per environment, and read them safely from your code.
Secrets keeps your workspace's sensitive values — API keys, passwords, tokens, connection strings — encrypted and out of your code. Each environment has its own set, so dev and prod can use different keys. Every time someone reveals a secret's value, it's recorded in the activity log.
Before you start
| To | You need |
|---|---|
| See which secrets exist | Member role or above |
| Reveal a value, or add and change secrets | Writer, Admin or Owner |
| Delete a secret | Writer, Admin or Owner |
Add a secret
Open Secrets
Go to Data → Secrets, and pick the workspace and environment at the top of the page.
Add it
Click Add secret, enter a key, such as STRIPE_API_KEY, and its value, then save. Keys are unique within an environment.
gf secrets set STRIPE_API_KEY - # paste the value, then press Ctrl+D
gf secrets lsReading the value with - keeps it out of your shell history. An empty value is refused. Add -e <environment-id> to choose the environment.
Naming rules
Your code reads secrets as environment variables, so a secret's key has to be a valid variable name:
- only letters, numbers and underscores (
_) - starts with a letter or an underscore
- at most 256 characters
| Valid | Not valid |
|---|---|
TELNYX_API_KEY, stripe_secret, _INTERNAL_TOKEN | telnyx-api (hyphen), 2FA_KEY (starts with a number), my.key (dot) |
A key that breaks these rules is refused with 422. When you import a .env file, lines whose keys break them are left out.
Groundfloor reserves some keys for itself: DATAPLANE_SERVICE_API_KEY and any key starting with MANAGED_DB_, in any letter case. You can't add, change or delete them (403).
Values are hidden in the list. To see one, click the eye icon; the reveal is logged. Never paste a revealed value into chat or email.
Some secrets are created and managed by Groundfloor, such as the credentials of a managed database. They're marked in the list and can't be edited or deleted there. The workspace's own data API key is marked (managed) and can't be revealed at all.
Use a secret in your code
| Your code | How it reads secrets |
|---|---|
| A Coderunner | At runtime, from the Secrets API, with the token of its attached machine client (Can read secrets). Secrets are never passed to a deploy or set as environment variables for you. See Configuration and secrets |
| A Shell app | Never directly: browser code is visible to everyone. Use a backend |
Don't paste a secret's value into a deploy as a plain environment variable: Groundfloor rejects deploys that send secret-looking names that way. Deploy-time secret references (gf deploy --secret, or secrets in the API) no longer exist, and a deploy that sends one is refused with 422 (secret_refs_removed). Read the secret when your code runs instead:
- The value comes from the environment you ask for. Pass the Coderunner's own environment (
GROUNDFLOOR_ENVIRONMENT_ID) asenvironment_idso a prod Coderunner reads prod's secrets. - A changed secret reaches your code the next time it reads it, with no redeploy.
- Reading needs Can read secrets on the attached client, which can read every secret in the workspace, in every environment.
Promote between environments
Copy secrets from one environment to another, for example staging to prod, under Build → Environments. The comparison shows which keys differ, never their values. See Environments.
Troubleshooting
| Problem | Likely cause | What to do |
|---|---|---|
| A secret you added isn't there | Another workspace or environment is selected | Check both pickers at the top of the page |
422 when adding a secret | The key has a hyphen, dot, space or other character, or starts with a number | Follow the naming rules, for example TELNYX_API_KEY instead of telnyx-api |
| You can't edit a secret | Groundfloor manages it | Change it where it comes from, such as the managed database |
403 when adding or revealing | Your role can only view secrets | Ask an Admin or Owner to raise your role |
A Coderunner gets 403 reading a secret | Its M2M client can't read secrets | Turn on Can read secrets for the client |
A deploy is refused with secret_refs_removed | The deploy named secrets (gf deploy --secret, or secrets in the API) | Send no secrets and read them at runtime |
A Coderunner reads 404 for a secret | The secret isn't set in the environment it asked for | Add it in that environment, or pass the right environment_id |
| A Coderunner still has a secret's old value | It read the value earlier and kept it | Read it again, or restart the Coderunner |
Next steps
- Configuration and secrets — give a Coderunner its secrets.
- Secrets API — manage secrets from code.
Environments
Keep dev, staging and prod apart, give each its own Shell site, then compare and promote secrets, flags, apps and Coderunners between them.
Feature flags
Per-environment typed feature flags — manage them in the portal or with gf flags, promote them across environments, and read them at runtime from Shell apps and Coderunners.