Groundfloor Docs

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

ToYou need
See which secrets existMember role or above
Reveal a value, or add and change secretsWriter, Admin or Owner
Delete a secretWriter, 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 ls

Reading 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
ValidNot valid
TELNYX_API_KEY, stripe_secret, _INTERNAL_TOKENtelnyx-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 codeHow it reads secrets
A CoderunnerAt 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 appNever 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) as environment_id so 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

ProblemLikely causeWhat to do
A secret you added isn't thereAnother workspace or environment is selectedCheck both pickers at the top of the page
422 when adding a secretThe key has a hyphen, dot, space or other character, or starts with a numberFollow the naming rules, for example TELNYX_API_KEY instead of telnyx-api
You can't edit a secretGroundfloor manages itChange it where it comes from, such as the managed database
403 when adding or revealingYour role can only view secretsAsk an Admin or Owner to raise your role
A Coderunner gets 403 reading a secretIts M2M client can't read secretsTurn on Can read secrets for the client
A deploy is refused with secret_refs_removedThe 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 secretThe secret isn't set in the environment it asked forAdd it in that environment, or pass the right environment_id
A Coderunner still has a secret's old valueIt read the value earlier and kept itRead it again, or restart the Coderunner

Next steps

On this page