Skip to main content
Toknbase
Setting up a full CI/CD pipeline?See the Pipeline Integration guide →
// @toknbase/cli

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.

@toknbase/cliNode.js 18+ESM

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.

1

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.

!The token is shown only once. Copy it immediately and store it securely.
2

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
Never commit your 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 NAME

Print the value of a single secret

read_only
toknbase list

List all secrets (names + environments, no values)

read_only
toknbase set NAME VALUE

Create or update a secret

read_write
toknbase export

Dump all secrets in .env format

read_only

get

read_only

Prints 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_only

Lists 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_write

Creates 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_only

Dumps 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
!Never commit the output oftoknbase 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.yml

Store 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 deploy

Pattern 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 deploy

GitLab CI

.gitlab-ci.yml
build:
 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.yml
jobs:
 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_TOKEN
required

Your agt_ agent token from the AI Agents dashboard.

TOKNBASE_CANISTER_ID
optional

Override the canister ID. Only needed for custom deployments.

Default:4wj64-piaaa-aaaan-q5q7q-cai

TOKNBASE_IC_HOST
optional

Override the Internet Computer boundary node. Defaults to icp-api.io.

Default:https://icp-api.io

Tip

Use toknbase export for local development only — not in CI/CD pipelines. For pipelines, use the REST endpoint directly to avoid writing secrets to disk.
Was this page helpful?