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

# Totebot CLI

> Manage agents, knowledge, the help desk and your team from the terminal

`totebot` is a command-line tool for everything the [Public API](https://docs.totebot.ai/api/public-api.md) can do. Coding agents such as Claude Code and Codex work especially well with it: you log in once, every command explains itself with `--help`, output is JSON, and common tasks need no code.

## Install

```bash theme={null}
npm install -g @totebot/cli
# or run it without installing
npx @totebot/cli --help
# or download the single file, without npm
curl -fsSL https://api.totebot.ai/v1/cli/totebot.js -o totebot && chmod +x totebot
./totebot --help
```

It needs Node.js 18 or newer and has no other dependencies. Once a day the CLI checks whether a newer version exists and prints a one-line notice to stderr when it runs in a terminal; set `TOTEBOT_NO_UPDATE_CHECK=1` to turn this off.

> [!NOTE]
>
> The CLI uses the Public API, so your plan needs the Public API (Basic, Pro or Scale).

## Sign in

```bash theme={null}
totebot login
```

The CLI opens the dashboard in your browser and shows a short code. Check that the code matches your terminal, then pick:

* **Team:** the team the CLI works on. You must be an owner of it, and its plan must include the Public API.
* **Scopes:** read access is selected, write access is off. Turn on only what you need, for example **knowledge:write** to update FAQs.
* **Agents:** all agents, or only some.

Approve, and the terminal is signed in and prints the team the key was approved for. If it is not the team you meant, run `totebot logout`. Behind the scenes, approving creates a team API key named after your computer. It shows up in **Team settings** → **API keys**, where you can **Edit access** or **Revoke** it like any other key.

The code expires after 10 minutes and works once. The key it creates expires after 90 days; run `totebot login` again to get a new one. If the team already has 25 active API keys, approval fails until you revoke one.

### Other ways to sign in

| Situation | How |
| - | - |
| You already have a key | `echo "$KEY" \| totebot login --api-key -` |
| CI, containers, sandboxes | Set `TOTEBOT_API_KEY`; no login needed |
| Several teams | `totebot login --profile acme`, then `--profile acme` on each command (or `TOTEBOT_PROFILE=acme`) |
| One-off | `--api-key <key>` on any command |

Check who you are signed in as with `totebot whoami`. `totebot logout` revokes the key and forgets it. If the revocation fails, the login is kept so you can retry; `--keep-key` only forgets it locally.

### Where the key is stored

On macOS the key goes into the Keychain, and on Linux into the Secret Service (through `secret-tool`). When neither is available, it goes into `~/.config/totebot/credentials.json`, readable only by you (mode 0600). Windows has no supported keychain, so the key is stored unencrypted in `%APPDATA%\totebot\credentials.json`, which only your Windows user can open; the CLI prints a warning when it saves a key there.

## How the CLI behaves

* **Output.** Tables on a terminal; JSON with `--json` or when output is piped. Only the result goes to stdout; messages and errors go to stderr.

* **Exit codes:**

  | Code | Meaning |
  | - | - |
  | 0 | Success |
  | 1 | Unexpected error |
  | 2 | Wrong command or flags, or the API rejected the input |
  | 3 | Not logged in, or the key lacks a scope (`details.missingScopes`) |
  | 4 | Not found |
  | 5 | Conflict (for example, a source is being trained) |
  | 6 | Rate limited (the CLI already waited and retried) |
  | 7 | Server or network error |
  | 8 | Cancelled (a destructive or confirm-required command was not confirmed) |
  | 9 | A bulk write failed on some agents, or was saved but training could not start (`error.details` holds every result) |
  | 10 | A check failed: `tests run --fail-under` found the pass rate below the threshold |
  | 11 | A run you waited for ended failed: `tests run --wait` (or `--fail-under`) got a FAILED test run, or `train start --wait` / `train wait` ended with failed knowledge sources or changes held back by the knowledge budget. The final status is still printed |

* **Dry runs.** `--dry-run` on any write prints the requests it would send, and sends nothing. Some commands also print `changes`: `agents update` and `widget set` show `{ field: { before, after } }`, `bulk update` the same per agent id, `agents rollback` shows `{ field: { from, to } }` plus the `skippedFields` it leaves alone, and `tests import` lists the questions it would add (`created`), change (`updated`) or leave (`unchanged`).

* **Confirmations.** Deleting, erasing, removing, applying a template and bulk deletes ask first, and so do commands that reach customers or change how agents answer: `tickets reply`, `agents update`, `agents rollback`, `bulk update`, `widget set`, `experiments start` and `experiments stop`. Without a terminal they need `--yes`.

* **Agents by name.** Any `<agent>` can be an id or an exact name, or come from `--agent` or `TOTEBOT_AGENT`.

* **Input from files.** `--file` and `--from-file` take a path, or `-` for stdin. Markdown works for text knowledge.

* **Safe retries.** Every write carries an `Idempotency-Key`, and rate-limited calls are retried after `Retry-After`.

## Next

> [card] [Command reference](https://docs.totebot.ai/cli/commands.md)
>
> Every command and its flags.

> [card] [Use with coding agents](https://docs.totebot.ai/cli/coding-agents.md)
>
> Claude Code and Codex setup and recipes.

> [card] [Optimize your agents](https://docs.totebot.ai/cli/optimize-agents.md)
>
> The full loop: analyse, test before applying, apply, verify, roll back.


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