Skip to content
Docs
strackt.io Open app

Manage secrets from the CLI

List, set, remove, and round-trip your environment's secrets with the strackt CLI.

Manage secrets from the CLI

The strackt secret:list, secret:set, secret:delete, secret:pull and secret:push commands let you manage your environment's secrets from the terminal — handy for scripting, CI, or just keeping your hands on the keyboard. They work on the same secrets you'd set in the dashboard, and changes take effect on the next deploy. Variables cannot be added, changed or removed while the application's changes are paused.

Environment selection follows one rule: explicit --env, then the environment pinned for this repository (strackt init) when --app is omitted, then the application's production environment or its only environment. If the choice is ambiguous, the command asks you to pass --env. For a non-interactive production write, add --production.

See what's set

strackt secret:list --env stg

Values are masked by default. To see them in plain text:

strackt secret:list --env stg --reveal

Masked reads need secrets:read or secrets:reveal; revealing values needs secrets:reveal. Writes need secrets:write. If your token lacks secrets:reveal, a reveal request returns an error instead of masked output.

Set or update a secret

strackt secret:set DATABASE_URL --value "postgres://…" --env stg

To keep a secret out of your shell history, pipe it in instead of passing --value:

cat secret.txt | strackt secret:set API_TOKEN --stdin --env stg

Keys must be uppercase letters, numbers, and underscores (e.g. STRIPE_SECRET_KEY). The CLI checks this before sending, so you get fast feedback on a typo.

Remove a secret

strackt secret:delete DEPRECATED_FLAG --env stg

Round-trip a whole .env file

Pull every secret for an environment into a local .env:

strackt secret:pull --env stg # writes .env in the current folder strackt secret:pull --env stg --output ./secrets.env strackt secret:pull --env stg --output - # print to the screen instead

pull always writes real values (a masked file would be useless), so it needs reveal access. On Mac and Linux the file is written with owner-only permissions. Keys come out sorted, so pulling the same set twice gives you an identical file.

Push a file back up:

strackt secret:push --file ./secrets.env --env stg

Add --prune to also remove any of your secrets that aren't in the file — so the environment ends up matching your file exactly:

strackt secret:push --file ./secrets.env --prune --env stg

Validation happens before any write: an invalid line leaves your existing secrets untouched. A storage failure during the write can leave some keys updated; retry the same push to finish it. A bulk update accepts at most 500 keys.

In scripts, deletion and push --prune also need --force. A production deletion or pruned push needs both --production and --force. The flags confirm different things.

A couple of things to know

  • No variable expansion. A value like $OTHER is stored as the literal text $OTHER, not the value of another variable. Your secrets are stored exactly as written.
  • Comments aren't kept. Comments in a file you push aren't stored, so a later pull won't bring them back.
  • --prune only touches the secrets you set. Connection details that strackt manages for you are never removed by a push.

When you pipe a pulled file to the screen with --output -, the values are visible — keep that in mind in CI logs, and redact before storing anything.

Was this helpful?