CLI Reference
The Toknbase CLI lets you fetch, store, and export secrets from any terminal or pipeline script. Zero config — authenticate once with an agent token and you're ready.
Installation
Install globally to use thetoknbasecommand anywhere, or usenpxfor one-off runs without installing.
Global install (recommended)
npm install -g @toknbase/cli
One-off via npx (no install required)
npx @toknbase/cli@latest get MY_SECRET
Verify installation
toknbase --version
No daemon or background process
Each CLI command is a single, stateless HTTP call to the Toknbase canister. Nothing runs in the background and no ports are opened.
Authentication
The CLI authenticates using a scopedagent token. Tokens are created in theAI Agentssection of your dashboard.
Create an agent token
Navigate toAI Agentsand create a new token. For most CLI use cases, chooseread_writescope so you can both fetch and set secrets.
Set the environment variable
For this session only
export TOKNBASE_AGENT_TOKEN=agt_your_token_here
Persist in shell profile (~/.zshrc or ~/.bashrc)
echo 'export TOKNBASE_AGENT_TOKEN=agt_your_token_here' >> ~/.zshrc source ~/.zshrc
agt_token to source control. Use your shell profile or a secrets manager for persistent storage.Verify authentication works
toknbase list
Should return your secrets list (or an empty array if you have no secrets yet).
Commands
Command reference
toknbase get NAMEPrint the value of a single secret
toknbase listList all secrets (names + environments, no values)
toknbase set NAME VALUECreate or update a secret
toknbase exportDump all secrets in .env format
get
read_onlyPrints the raw value of a single secret to stdout. Designed for shell substitution — the output contains only the value with no extra formatting.
toknbase get MY_SECRET
Shell substitution (most common use case)
export STRIPE_KEY=$(toknbase get STRIPE_SECRET_KEY) npm run deploy
Pass directly to a command
STRIPE_KEY=$(toknbase get STRIPE_SECRET_KEY) node server.js
list
read_onlyLists all secrets accessible to the current token. Returns names, environments, and descriptions — never plaintext values.
toknbase list
Example output:
NAME ENVIRONMENT DESCRIPTION STRIPE_SECRET_KEY production Stripe live secret key STRIPE_WEBHOOK_SECRET production Stripe webhook signing secret OPENAI_API_KEY production OpenAI API key DATABASE_URL staging Postgres connection string
set
read_writeCreates a new secret or updates an existing one. If the named secret already exists, its value is updated. Requiresread_writeorfull_accessscope.
toknbase set MY_SECRET my-secret-value
Quote values with spaces or special characters
toknbase set DATABASE_URL"postgres://user:pass@host:5432/db"
Pipe value from another command
openssl rand -hex 32 | toknbase set APP_SECRET
export
read_onlyDumps all accessible secrets in.envformat (KEY=VALUE per line). Suitable for piping into a file or sourcing directly into the current shell.
toknbase export
Write to a .env file
toknbase export > .env
Source directly into the current shell session
source <(toknbase export)
Filter by environment (coming soon)
toknbase export --env production > .env.production
toknbase export to source control. Add .env to your.gitignore.CI/CD Integration
The CLI is a drop-in replacement forcurl | jqcalls in pipeline scripts. Install it in your pipeline runner and calltoknbase getortoknbase exportto inject secrets.
GitHub Actions
.github/workflows/deploy.ymlStore your agent token as a GitHub Actions secret namedTOKNBASE_AGENT_TOKEN.
Pattern 1 — export entire vault as .env
name: Deploy
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Toknbase CLI
run: npm install -g @toknbase/cli
- name: Load secrets
run: toknbase export >> $GITHUB_ENV
env:
TOKNBASE_AGENT_TOKEN: ${{ secrets.TOKNBASE_AGENT_TOKEN }}
- name: Build & Deploy
run: npm ci && npm run deployPattern 2 — single secret via $GITHUB_OUTPUT
- name: Fetch Stripe key
id: secrets
run: echo"STRIPE_KEY=$(toknbase get STRIPE_SECRET_KEY)" >> $GITHUB_OUTPUT
env:
TOKNBASE_AGENT_TOKEN: ${{ secrets.TOKNBASE_AGENT_TOKEN }}
- name: Deploy
env:
STRIPE_KEY: ${{ steps.secrets.outputs.STRIPE_KEY }}
run: npm run deployGitLab CI
.gitlab-ci.ymlbuild: image: node:20 script: - npm install -g @toknbase/cli - toknbase export > .env - source .env && npm ci && npm run build artifacts: paths: - dist/
CircleCI
.circleci/config.ymljobs: build: docker: - image: cimg/node:20.0 steps: - checkout - run: name: Load secrets command: | npm install -g @toknbase/cli toknbase export >> $BASH_ENV - run: name: Build command: npm ci && npm run build
Full platform coverage
For Vercel, Bitbucket Pipelines, and more — including the rawcurlendpoint alternative — see thePipeline Integration guide.
Environment Variables
All configuration is passed via environment variables. Only the agent token is required — the rest are optional overrides.
Configuration
TOKNBASE_AGENT_TOKENYour agt_ agent token from the AI Agents dashboard.
TOKNBASE_CANISTER_IDOverride the canister ID. Only needed for custom deployments.
Default:4wj64-piaaa-aaaan-q5q7q-cai
TOKNBASE_IC_HOSTOverride the Internet Computer boundary node. Defaults to icp-api.io.
Default:https://icp-api.io
Tip
toknbase export for local development only — not in CI/CD pipelines. For pipelines, use the REST endpoint directly to avoid writing secrets to disk.