---
title: "Keep a secret value out of chat"
description: Store a secret's value from a file or by typing it in your own terminal, so it never appears in the chat, a tool call, or a command your AI coding tool records.
slug: /guides/supply-a-secret-value-without-exposing-it
order: 21
visibility: public
redirects_from: [/guides/keep-a-secret-value-out-of-chat]
---

# Keep a secret value out of chat

Prompt:

> Give the app my API key, but don't paste it into the chat.

Also works:

- "I'll type the password myself. Give me the command to run."
- "Make a signing secret for the backend that nobody needs to see."
- "My tool can't run the secret command here. How do I store the key?"

For a value only you hold, `store_secret` returns a command line for your computer to run. That line reads the value from a file ([Store a value from a file](#store-a-value-from-a-file)). Without a file, the command asks you to type the value in your own terminal ([Type the value in your own terminal](#type-the-value-in-your-own-terminal)). Either way, the value never passes through the chat.

## What your AI tool does

- Reads the `store-key` skill (`read_context`, id `skill:store-key`) and follows it, as [Store a secret](/cloud/getting-started/store-a-secret/#what-your-tool-does) lists.
- Names the file by an absolute path, or by a path relative to the folder where the command runs. It never uses `~`.
- Never prints the value's file, never reads it back, and never writes the value into a command: a value the conversation already holds goes to `store_secret` instead ([When no person is present](#when-no-person-is-present)).
- Where you will type the value, gives you the command and asks you to run it in your own terminal before `expires_at`, the time the command stops working.
- Where the command cannot run and the platform cannot create the value, asks you to store the value yourself on the signed-in site.

## What you need

- The value, saved in a file outside your application's folder, or ready to type into a terminal of your own.

## Before your AI starts

**For the AI tool:** Check the following before starting.

- The name and the scope to store the value under: the account, or one environment of an application ([Choose the name and the scope](/cloud/getting-started/store-a-secret/#1-choose-the-name-and-the-scope)).
- Whether you are there to point at a file or to run the command in your own terminal.
- Node.js 24 or later and npm, to run the turnzero command through npx or a global installation ([What your computer needs](/cloud/getting-started/prerequisites/)).

## Steps

Prefer a local file, your own terminal, or the signed-in site to keep the value out of chat and tool transcripts. You may deliberately paste an application secret into chat for your AI tool to store; that alone does not require rotation. When using a file, have the command read it without printing its contents.

### Store a value from a file

This is the common case: the value is in a file on your machine, and your AI tool runs the command. It first uses the returned `command_npx`, or `command_npx_windows` on Windows, once, exactly as given. [Running and writing lines](/cloud/concepts/turnzero-command/#running-and-writing-lines) explains what to do if npx can't run here.

Your AI tool calls `store_secret` with the name, the scope, no value, and `value_file`, the path of the file that holds the value. The path is absolute or relative to the folder where the command runs. The home folder is written in full, never as `~`. The platform never reads the path. The call stores nothing. Its response has:

- `state`, which is `awaiting_value`;
- `command`, one command line for macOS and Linux;
- `command_windows`, the same command for Windows, with `turnzero.cmd` in place of `turnzero`;
- `command_npx` and `command_npx_windows`, the same two lines through npx, whether or not turnzero is installed globally;
- `expires_at`, fifteen minutes after the call. After that time, the command is refused;
- `detail`, which says who runs the command.

The returned command invokes [the turnzero command](/cloud/concepts/turnzero-command/) with a secret grant: a short-lived credential that allows one write of that name at that scope. The command reads the value on your machine, sends it once, and prints neither the value nor the grant.

Your AI tool runs the command for your operating system once, exactly as returned, before `expires_at`. A second run after its write landed is normally refused. A line changed to give another name or scope is refused. `store_secret` with `replace: true` works the same way and returns a `secret rotate` line ([Replace a value](/cloud/getting-started/store-a-secret/#3-replace-a-value)).

The value's file is kept outside your application's folder, because a deploy's zip includes every file of that folder but `node_modules`, `.git`, the `.env` files, and the AI coding tools' own files. A value's file left in the folder would enter the [artifact](/cloud/concepts/glossary/#artifact). Where a deploy from the folder the command runs in would include the file, the command prints a line that opens `warning:` and stores the value all the same.

A `value_file` path that a shell would change in the command is refused 400 `invalid_request`, and no line is returned. Such a path has a control character, a double quote, `$`, a backtick, `%`, `!`, `&`, `|`, `<`, `>`, `^`, a typographic double quote, a doubled backslash, or a trailing backslash.

A `value_file` that is `~` alone or starts with `~/` or `~\` is refused the same way. Write the home folder in full. A name such as `~draft.txt` is admitted if it meets the other path rules.

The two samples below show the command's form. `<grant>` stands in for each call's own grant, so run the command your call returns, never a sample. The first is `command` for a call that names `../secrets/stripe-webhook-secret.txt` as `value_file`, a file in a folder beside the application's folder:

```text
echo <grant> | turnzero secret store --name stripe-webhook-secret --application 3f6c2a1e-8d4b-4c7a-9e21-5b0f7d9c4a13 --environment production --value-file "../secrets/stripe-webhook-secret.txt"
```

This is `command_windows` for the same call:

```text
echo <grant> | turnzero.cmd secret store --name stripe-webhook-secret --application 3f6c2a1e-8d4b-4c7a-9e21-5b0f7d9c4a13 --environment production --value-file "../secrets/stripe-webhook-secret.txt"
```

If your AI tool is connected to a platform other than https://turnzero.ai, the returned command includes `--origin` with that platform's address. You do not need to set the address yourself.

### Type the value in your own terminal

With no `value_file`, you run the command yourself, not your AI tool. The command ends with `--value-prompt`, and you run it in a terminal of your own. It asks for the value without showing it, and Enter ends the value, within five minutes, the command's own wait. The terminal must also show the command's output. A noninteractive command runner cannot accept this input: the command refuses it and sends nothing. Your AI tool gives you the command to run in your own terminal.

The prompt reads the terminal itself, never standard input, which carries the grant, so a value piped in is never read as the value: the command reads piped input as the grant. A pseudo-terminal that shows the command's output works as a terminal does. Your AI tool never types the value into one itself, since the value would then pass through its own tool call.

This is `command` for the same call with no `value_file`:

```text
echo <grant> | turnzero secret store --name stripe-webhook-secret --application 3f6c2a1e-8d4b-4c7a-9e21-5b0f7d9c4a13 --environment production --value-prompt
```

### Read the value from a variable a machine sets

The file route above is the default. Where a machine already holds the value in an environment variable, the command can read it from there. Examples are a variable a continuous integration (CI) service sets from its secrets store, or one in your AI tool's own process.

Your AI tool calls `store_secret` as for a file. In the command the call returns, your AI tool puts `--value-variable` and the variable's name in place of `--value-file` and its path. The command names the variable, never its value. A variable that is unset, empty, or holds only spaces is refused, and nothing is sent. So is a variable the command reads its own credential from, `TURNZERO_CLOUD_MINTED_TOKEN` or `TURNZERO_CLOUD_UPLOAD_GRANT`, written in any case.

This is `command` for the same call, with the value in the variable `STRIPE_WEBHOOK_SECRET`:

```text
echo <grant> | turnzero secret store --name stripe-webhook-secret --application 3f6c2a1e-8d4b-4c7a-9e21-5b0f7d9c4a13 --environment production --value-variable STRIPE_WEBHOOK_SECRET
```

### When no person is present

The platform creates a value nobody chooses itself, such as a session signing secret, so the value never passes through a file or the transcript. Your AI tool takes this route for every such value at an application's scope, whether or not a person is present:

1. Your AI tool calls `store_secret` with `name`, `application`, `environment`, and `generate`. `generate` is either `base64url_32` (32 random bytes as 43 characters) or `hex_32` (32 random bytes as 64 hexadecimal characters). The call returns no command line and never returns the value. It refuses a name already stored at that scope.
2. Your AI tool binds a setting to the name in the manifest's `settings`, so your deployed application reads the value as that setting. Then your AI tool deploys.

A created value exists in the deployed environments alone, so a local run sets its own value for that setting. Your application's own code is the one place the value is read, so a secret an outside service must also hold, such as a webhook's signing secret, is supplied rather than created.

`store_secret` with `replace: true` creates no value, so a created value is replaced under a new name. Your AI tool stores a new name with `generate`, binds the setting to it, and deploys. Then it deletes the old name with `delete_secret`, which you approve in the browser.

Two cautions go with replacing a created value. Create the new name at each environment the application deploys to before the deploy and the promote, because a created name is stored at one environment's scope only. Keep the old name while you might roll back to a version that binds it, because nobody can store a created value again.

A value stored while nobody is present is never shown again. If you must keep it or give it to an outside service, supply a value you hold rather than have one created. If a job has stored one you cannot read, supply a new value under the same name with `store_secret` and `replace: true`. Follow the answer's `next` to restart the affected environment where needed ([Replace a value](/cloud/getting-started/store-a-secret/#3-replace-a-value)). This replaces the value; it does not recover the old one.

For a value the platform cannot create, the tool uses the one-step file route below.

A tool that works with no person present can supply a value that the tool itself creates, such as a key longer than the 32 bytes `generate` creates. A value at the account scope, which `generate` does not reach, is another. It writes the value, runs the command, and deletes the file in one shell step:

1. It learns the operating system's temporary folder with `node -p "require('node:os').tmpdir()"`, which prints a folder and no value.
2. It names a new file in that folder by its absolute path, with a random part in the file's name, and calls `store_secret` with that path as `value_file`. The file need not exist yet, because the platform never reads the path.
3. In one shell step, it writes the value into that file, runs the command the call returns, and deletes the file.

One step keeps the file where the command reads it. A relative path can point to no file when the command runs from another folder. The command then refuses with `ENOENT`. A path that is `~` alone or starts with `~/` or `~\` is refused by `store_secret` before it returns any command.

For example, this step writes 48 random bytes as text into the file, runs `command`, and deletes the file. It is for bash or zsh on macOS and Linux. `/tmp` stands for the folder step 1 printed:

```text
node -e "require('node:fs').writeFileSync(process.argv[1],require('node:crypto').randomBytes(48).toString('base64url'),{mode:0o600,flag:'wx'})" "/tmp/long-signing-key-7f3a.txt" && { echo <grant> | turnzero secret store --name long-signing-key --application 3f6c2a1e-8d4b-4c7a-9e21-5b0f7d9c4a13 --environment production --value-file "/tmp/long-signing-key-7f3a.txt"; rm -f "/tmp/long-signing-key-7f3a.txt"; }
```

This is the same step in PowerShell on Windows, with `command_windows`:

```text
node -e "require('node:fs').writeFileSync(process.argv[1],require('node:crypto').randomBytes(48).toString('base64url'),{mode:0o600,flag:'wx'})" "C:\Users\me\AppData\Local\Temp\long-signing-key-7f3a.txt"; if ($LASTEXITCODE -eq 0) { echo <grant> | turnzero.cmd secret store --name long-signing-key --application 3f6c2a1e-8d4b-4c7a-9e21-5b0f7d9c4a13 --environment production --value-file "C:\Users\me\AppData\Local\Temp\long-signing-key-7f3a.txt"; Remove-Item "C:\Users\me\AppData\Local\Temp\long-signing-key-7f3a.txt" }
```

In cmd, follow the write with `&&`, then put the command and a `del` of the file in parentheses. Git Bash on Windows runs the bash form, the first sample, with `command_windows` as the command inside its braces and the folder step 1 printed. It never runs the PowerShell or the cmd form, whose delete it does not have.

The write refuses where a file already exists at that path, and the step then runs nothing more: your AI tool names a new file and makes a fresh call. A step stopped before the command ends leaves the file behind, so delete it by hand. A printed line that opens with `stored:` or `rotated:` means the value was written. On any other outcome, your AI tool makes a fresh call and runs a fresh step with a new value.

Your AI tool gives a file as `value_file` without a copy only if it is outside the application's folder and holds the value alone, such as a `.p8` key file. Otherwise, as with a `.env` line, it writes the value alone to a new file outside the application's folder without printing it. It passes that path as `value_file` and deletes the file after the command ends. A value handed to your AI tool in the conversation itself goes to `store_secret` as `value`: the transcript holds it already, so the call adds no exposure.

Some coding tools check each shell step before it runs. They can refuse the one-step route because it writes a credential to a file. Claude Code's auto mode does this, and names the reason `Credential Materialization`. Your AI tool then stops and tells you. It never rewrites the step to get past the check. Either you run the step yourself, or you allow it in your AI tool's permission settings, as the refusal says.

With nobody present to run or allow a refused step, or where no shell step can run, your AI tool stops and asks you for a value the conversation does not hold. It tells you the name and the scope, and you store the value on the signed-in site’s **Secrets** page ([When the line cannot run](#when-the-line-cannot-run)).

A value that only you know, such as a key a provider issued to you, needs you. No tool can supply it. Your AI tool gives you the command to run in your own terminal before `expires_at`, or uses a file you saved outside your application's folder as `value_file`.

A job that runs with no AI coding tool, such as a CI job that holds the value in its own secret store, has one more route. It needs no terminal and no file. It sends `store_secret` with `value` to `POST https://tzcloud.turnzero.ai/v1/store_secret`, under its own minted token. A session your AI coding tool drives keeps the command and its grant instead, so the value never passes through the tool's context.

### A password a person signs in with

For your application's admin access, use sign-in by emailed code with your verified address stored and bound as `OWNER_EMAIL` ([Let only you reach an admin route](/cloud/guides/add-sign-in-to-your-app/#6-let-only-you-reach-an-admin-route)). Do not create a shared admin key or password.

If a person must type a password, that person chooses it. A value created with `generate` is never returned or shown again, so it cannot serve as a password someone must know.

To store your chosen password, open **Secrets** → **Add a secret** on the signed-in site, or type it in your own terminal with `--value-prompt` ([Type the value in your own terminal](#type-the-value-in-your-own-terminal)). Your AI tool gives you the name and scope; it never prints, writes or sends the value you enter there.

You may choose to paste the value into chat for `store_secret` to store, but that copy remains in the conversation.

### When the line cannot run

Some sessions cannot use the command at all. Their shell is blocked, or it can write no file, set no variable, and reach no terminal. The value then takes one of three routes:

- A value nobody needs to choose at an application's scope, such as a session signing secret, is created by the platform with `generate`, as [When no person is present](#when-no-person-is-present) describes. No line runs.
- A value you already put in the conversation goes to `store_secret` as `value`, at any scope, development included. No line runs, and the call adds no exposure, because the transcript holds the value already.
- You store any other value yourself on the signed-in site. Open **Secrets** → **Add a secret** at `https://turnzero.ai/dashboard/secrets`. Enter the name and value. Choose **All apps** for the account’s scope, or choose an application. If the application has two environments, choose **Production** or **Development**; an application with one stores the value in production. Choose **Save secret**. Your AI tool tells you the name and scope, and you type the value there ([Use the signed-in site](https://turnzero.ai/turnzero/guides/your-account/#3-use-the-signed-in-site)).

Your AI tool never puts a value the conversation does not already hold into a tool call, a command, or a message to get around a blocked line. Each of those reaches the transcript.

### How the value stays out of the transcript

A transcript records your AI tool's calls, the commands it runs, and their output. The value appears in none of these, unless it was already in the conversation:

- **No tool call has it.** `value_file` is a path. One exception: a value you already put in the conversation, your AI tool may pass to `store_secret` as `value`, with or without `replace: true`, since the transcript holds it already. A value on disk, or one only you know, goes through the command, which never shows it to your AI tool.
- **No command line has it.** The command has the grant and the path, never the value. Your AI tool never writes the value into a command, for example to fill a file or a variable, because the command would reach the shell's history and the transcript. The one-step file route makes its value inside the step, so its command names the generator and never the value. A value already in the conversation goes to `store_secret` as `value` instead, so no step writes it.
- **No output has it.** The command prints the action's result, never the value or the grant. Your AI tool never prints the file and never reads it back.

The secret grant appears in the transcript, inside the command. Anyone who holds it can use it for one write of that name at that scope before `expires_at`. It permits no other action. Once your command's write has landed, the grant is normally spent.

### What the command reads and prints

The command reads the file as UTF-8. It drops a byte-order mark and one final line ending. It refuses a UTF-16 file before sending anything. In Windows PowerShell 5.1, save the file with `Set-Content -Encoding utf8`, never with `>` or `Out-File`, which write UTF-16 there.

With no grant piped, the command prints a line that says so and names this computer's token for the address, before the write. As the write goes out, and before its response comes, the command prints a line that says the write is being sent. That line says `list_secrets` shows whether the write landed, so check there before any second run. Under a grant, it also says the grant serves once, so a second run is normally refused where this write landed.

The command sends the value in one write. Where the answer is a redirect to another address, the command does not follow it, so the value goes to no second address. It never makes the write again, because the first request may have reached the platform. Where that write landed, a second run of the same command is normally refused `secret_grant_spent`, and a new call from your AI tool returns a fresh command.

If the platform refuses a write, or the write fails before storing the value, the grant normally becomes usable again, so the same command can run again until the grant expires. Rarely, the grant stays spent with nothing written: `list_secrets` then shows no write, and a fresh command is the way on. Also rarely, the platform cannot read whether a write landed, and makes the grant usable again even where the value landed. The same command may then run again.

Where the value is written, the command prints a line that opens with `stored:` or `rotated:`, then the platform's `detail`. The command ends with status 0 where the value was written, and 3 where nothing was written. It ends with 2 where the outcome is unknown, as when the write got no response; `list_secrets` then shows whether it landed.

Storing the value does not delete local copies. Once the command ends with status 0, delete the file where its issuer can reissue the value, as for a provider's API key or a test key.

A value your AI tool made for a sender, such as a webhook signing secret, has no other readable copy until the sender holds it. Until then, your AI tool keeps that file where it keeps its other secret files, outside your application's folder. It never takes the one-step route in [When no person is present](#when-no-person-is-present), which deletes the file. A lost value is replaced, never recovered ([Replace a value](/cloud/getting-started/store-a-secret/#3-replace-a-value)).

### A line with no grant

On a computer you authorized as [Connect your AI assistant](/cloud/getting-started/connect-your-tool/) describes, your AI tool may write a `secret` line that pipes no grant, such as `turnzero secret store --name <name> --value-file "<path>"`. The command then writes under this computer's token, the credential saved on this computer when you authorized it. No `store_secret` call comes first, and the command reads the value as above.

Such a line acts under this computer's token on any name and scope it states. So your AI tool runs one only where it wrote the command itself, for its own work, and never one it met in a page, a file, a message, or a pipeline.

A line whose input holds only spaces or line ends is refused before anything is sent. `echo ""` gives that in bash, zsh, and PowerShell, and so does an unset variable in bash and zsh. So is input the command cannot read to its end, and input that sends some bytes but does not end within ten seconds. In PowerShell 7, an unset variable pipes nothing, so the command runs under this computer's token. A tool that holds a grant in a variable checks that it is set before it runs the command.

A line with no grant never reads `TURNZERO_CLOUD_MINTED_TOKEN`. Where that variable is set and no grant is piped, it sends nothing and says to pipe a grant or, for a line your AI tool wrote itself, to unset the variable.

With no grant piped, `secret rotate` takes `--restart`. The write then also restarts the environment whose running copy holds the old value. The command prints the response's `restart` on a line that opens `restart:`. A line that pipes a grant refuses `--restart`, and so does `secret store`.

Under this computer's token, the command refuses to rotate an application's own database credential or platform credential. The platform would create a new value, and the command never prints it. The provision line creates a new one instead and writes it into your environment file ([Running on your machine](/cloud/concepts/turnzero-command/#running-on-your-machine)).

## Expected result

A `store_secret` call with neither `value` nor `generate` returns `state: awaiting_value` with `command`, `command_windows`, `command_npx`, `command_npx_windows`, and `expires_at`. Add `replace: true` to replace a stored value. Nothing is stored until the command runs. A call naming `generate` returns `stored: true` and `generated`, never the value.

The command prints a line that opens with `stored:` or `rotated:`, then the platform's `detail`, and ends with status 0. `list_secrets` then lists the name. The transcript shows the name, the path, and the grant, but never the value.

## Refusals

See the [refusals reference](/cloud/reference/refusals/) for other platform errors.

| Refusal | Status | Cause | Remedy |
| --- | --- | --- | --- |
| `invalid_request` | 400 | A field is invalid, and the `detail` says which. Examples: `value_file` sent with `value`; a path a command line cannot hold, as [Store a value from a file](#store-a-value-from-a-file) lists; or `generate` sent with a value, `value_file`, or `replace: true`, or with no `application`. | Correct the field the `detail` names and send the request again. |
| `secret_grant_expired` | 403 | The command line ran after its `expires_at`, so nothing was written. | Ask your AI tool to call `store_secret` again for a fresh command. Leave `value` out and keep `replace: true` for a replacement. Run the command before its `expires_at`. |
| `secret_grant_spent` | 403 | The command presented a secret grant that was used earlier, so this run wrote nothing. A grant permits one write only. Where a command's first run is refused this way, someone else used its grant first, and the stored value may not be yours. | Do not run the same command again. `list_secrets` shows when the name was last written. Where it shows no write from your command, ask your AI tool to call `store_secret` again for a fresh command. Leave `value` out and keep `replace: true` for a replacement. Run the command. |
| `secret_grant_not_admitted` | 403 | The command was changed to give another name, action, application, or environment than the call that returned it. Nothing was written, and the grant is not spent. | Run the command exactly as the call returned it. For another name or scope, ask your AI tool to call `store_secret` for that name and scope. Leave `value` out and keep `replace: true` for a replacement. Run the command it returns. |
| `authentication_required` | 401 | For a command line, the `detail` says "The grant this request presented was not accepted": that grant expired and was removed, or the command's secret grant was changed. | Ask your AI tool to call `store_secret` again for a fresh command. Leave `value` out and keep `replace: true` for a replacement. Run the command. |

## Related

- [Store a secret](/cloud/getting-started/store-a-secret/) chooses the name and the scope, and replaces, lists, and deletes a stored value.
- [The turnzero command](/cloud/concepts/turnzero-command/) describes `turnzero`, its options, and its exit statuses.
- [Secrets](/cloud/troubleshooting/secrets/) in Troubleshooting starts from what a refused command line prints.
- [Secret grant](/cloud/concepts/glossary/#secret-grant) in the glossary defines the short-lived credential inside the command.
- [store_secret](/cloud/reference/actions/store-secret/) in the generated reference gives the action's arguments and result.
