Environment secrets from stdin
An environment holds the address of the app you test and, when the app needs it, a secret: a bearer token, a basic-auth password or an API key.
An environment holds the address of the app you test and, when the app needs it, a secret: a bearer token, a basic-auth password or an API key. The heybug env commands set these values, but they never take a secret as a flag. You pipe the value in on standard input instead. The server stores it encrypted and never sends it back. heybug env get only shows which fields are set.
Why values come from stdin
- Shell history keeps flags. A value typed as a flag is often saved in your shell history.
- Other users can see flags. Arguments show up in the process list (
ps) while the command runs. Standard input does not. - Your password manager already holds the value. Piping its output means you never write the secret into a file or script.
- Flags for secrets do not exist. There is no
--token,--passwordor--api-keyflag, soheybug envrejects one with a usage error (exit code 2).
Set a secret
- Find the environment ID with
heybug env list --project <project id>. - Choose the auth type the environment uses.
--secret-stdinworks with three of them:
--auth | The piped value is stored as |
|---|---|
bearer | Token |
basic | Password |
apikey | API key |
- Pipe the value into
heybug env update(orheybug env create) with--secret-stdinand the same--auth. The command reads one line, trims the spaces and line break around it, and uses it as the secret. - Check the result with
heybug env get. Thesecretsobject showstruefor each field that is set. The value is never printed.
Typing the value by hand also works, but the terminal may show what you type. Piping avoids that.
Example
Replace the placeholders with your project and environment IDs and with your password manager's read command. Flags go before the environment ID, because the command stops reading flags at the first word that is not one.
# Replace the placeholder with your password manager's read command.
<password-manager-cli> read "heybug/staging-token" \
| heybug env update --project prj_123 --auth bearer --secret-stdin env_456To create a new environment with the same secret:
<password-manager-cli> read "heybug/staging-token" \
| heybug env create --project prj_123 --name staging \
--url https://staging.example.com --sign-in public --auth bearer --secret-stdinA successful write prints one line, for example env create: ok env_456. Then check it:
heybug env get --project prj_123 env_456The output is JSON. Its secrets object shows which fields are set, for example "token": true, and the value is missing from the output.
To set the project once for a shell session, export HEYBUG_PROJECT_ID=prj_123 and leave out --project.
Several fields at once
For custom headers or several secret fields together, use --credential-file with a JSON file shaped like {username, password, token, apiKey, headers}. The file holds the secrets in plain text, so keep it out of git and delete it after the command runs. Use --secret-stdin for a single value.
When it fails
| Message or symptom | What it means | What to do |
|---|---|---|
--secret-stdin needs --auth bearer, basic or apikey | The command has no --auth, or the auth type has no secret field. | Add --auth bearer, basic or apikey to the same command. |
no secret on stdin (exit code 5) | The pipe was empty, or the read command printed nothing. | Run the read command by itself. It should print one line. |
--name and --url are required | env create was missing a name or a URL. | Pass both --name and --url. |
--project or HEYBUG_PROJECT_ID is required | The command does not know which project to use. | Pass --project, or export HEYBUG_PROJECT_ID. |
usage: heybug env update <env id> | The environment ID is missing, or it sits before a flag. | Put the ID last, after the flags. |
flag provided but not defined | You tried a secret flag such as --token. | Remove it and pipe the value with --secret-stdin. |
environment <id> not found (exit code 4) | The ID is wrong, or it belongs to another project. | Run heybug env list --project <project id> and copy the ID again. |
| Exit code 3 | You are not signed in. | Run heybug auth status, then sign in. See the CLI guide. |
| The server refuses the write | Your role is viewer. Only owners, admins and members can change environments. | Ask an owner, admin or member to make the change. |
Every exit code is listed in CLI exit codes.
Related guides
- CLI: signing in and the full command list.
- Getting started: your first project and run.
- MCP: the tools your coding agent can call. Environment changes are CLI only for now, so use this page's commands.
- Project settings: browser and run settings for each project.
- CI security: keeping secrets out of pipeline logs.