> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ancha.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These docs describe the Ancha CLI, npm package @ancha-labs/cli version 0.1.4, and the hosted workspace at app.ancha.io. Coding agents should start at https://docs.ancha.io/coding-agents. Run the CLI as `ancha` after `npm install -g @ancha-labs/cli`, or as `npx -y @ancha-labs/cli@0.1.4` without installing. Pass --json for machine-readable output, or set ANCHA_JSON=1. Every command ends with a `next:` line naming the next command. Exit codes: 0 pass, 1 a check failed or a comparison regressed, 2 usage, config or authentication error, 3 infrastructure error, 4 unimplemented endpoint with --strict.

# ancha secrets

> Copy model provider keys and other variables from your shell into your hosted workspace, list their names, or remove them. Values never appear in arguments or output.

`ancha secrets` manages the variables your agents receive when they run in your hosted workspace, such as `OPENAI_API_KEY`. Values come from your current shell's environment, never from command arguments, and the CLI never prints them.

Sign in first with [`ancha login`](https://docs.ancha.io/cli/login), or set `ANCHA_SERVER_URL` and `ANCHA_API_KEY`.

## ancha secrets set

```bash theme={null}
ancha secrets set [options] <names...>
```

| Argument | Description |
| - | - |
| `names` | Variable names to copy from this environment, e.g. OPENAI\_API\_KEY |

```bash theme={null}
export OPENAI_API_KEY=...   # in your shell, not in the command
ancha secrets set OPENAI_API_KEY
```

```text Output theme={null}
Set OPENAI_API_KEY. Workspace variables: OPENAI_API_KEY. Restarting the workspace processes; give it a few seconds.
```

Names are upper snake case, up to 64 characters. The workspace restarts its processes to pick up the change.

## ancha secrets list

```bash theme={null}
ancha secrets list [options]
```

Prints the names, one per line, never the values.

## ancha secrets unset

```bash theme={null}
ancha secrets unset [options] <name>
```

```text Output theme={null}
Removed OPENAI_API_KEY. Remaining: none.
```

## Errors

| Message | Exit | Cause |
| - | - | - |
| `secrets live in a hosted workspace` | 2 | Not signed in, or the server is local. |
| `OPENAI_API_KEY is not set in this shell` | 2 | Export the variable before `set`. |
| `secret names are UPPER_SNAKE_CASE, up to 64 characters` | 2 | Rename the variable. |

See [Secrets](https://docs.ancha.io/cloud/secrets.md) for which agents receive them.


## Related topics

- [Secrets](https://docs.ancha.io/cloud/secrets.md)
- [Troubleshooting](https://docs.ancha.io/troubleshooting.md)
- [Environment variables](https://docs.ancha.io/reference/environment-variables.md)
- [CLI overview](https://docs.ancha.io/cli/overview.md)
- [Changelog](https://docs.ancha.io/changelog.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.