CLI

The apivault command-line client manages your encrypted API keys from the terminal, injects secrets into local processes, and exports dotenv files for frameworks that need them — interactively on your machine, or headless in a pipeline.

To try commands in your browser, open the Interactive Shell from the bottom corner of the docs. Use its three-dot menu to choose Demo mode for sample data or Live mode for your vault. Live mode requires signing in. The shell runs keys, projects, logs, config, and whoami, and prints the same --help text as the installed CLI. It uses its own settings: there are no config files, so --local and --global aren't available, and a vault key you set stays in the tab's memory. Commands that need your machine, such as run, env, and logs --follow, only work in the installed CLI. When an example only offers Copy code, paste it into your own terminal.

Installing the CLI

The CLI needs Node.js 18.17.0 or newer.

Shell
npm install -g apivault

Or run it on demand without a global install:

On-demand executionShell
npx apivault <command>

Updating the CLI

Re-run the command for your installation method. If you installed with npm, you can specify the latest tag as shown below. See the changelog for version details.

Update with npmShell
npm install -g apivault@latest

Checking the version

VersionShell
apivault --version

Running apivault with no arguments prints whether this device is signed in, and tells a token that was never issued apart from one that has expired.

Quick start

The most common workflow is using apivault run to inject secrets into your local development server without ever writing them to disk:

  1. Authorize your terminal

    Connect the CLI to your account through browser approval:

    Sign inShell
    apivault login
  2. Bind the repository to the project whose keys it uses. Find the ID with apivault projects list.

    Link the projectShell
    apivault link <id>
  3. Set a default environment (optional)

    Save the environment so you don't have to pass --env on every run:

    Set the default environmentShell
    apivault config set run.env Development
  4. Inject secrets and start your app

    Start the dev serverShell
    apivault run -- npm run dev

Using the CLI in CI/CD

apivault login needs a browser, which a pipeline does not have. Create a service token for the project and expose it to the job as APIVAULT_TOKEN; every command then authenticates as that token instead of a signed-in user. Keep it in your CI provider's secret store rather than in the workflow file.

After setting APIVAULT_TOKEN, verify which identity the CLI is using.

Verify the service tokenShell
apivault whoami

Run the build with the project's Production secrets.

Build with Production secretsShell
apivault run --env Production -- npm run build

A service token reaches keys only, so a few commands refuse to run under one. Scopes, environment pins and the full compatibility table are on CI/CD & service tokens.

Available commands

Every command accepts the global options, including --json and --project.

For the apivault link and apivault unlink shortcuts, see the projects command reference.

config

Read and write the local and global defaults other commands fall back on.

apivault configShell
apivault config list

Learn more about apivault config

env

Write an environment's secrets to a dotenv file, or restore files hidden by run.

apivault envShell
apivault env export --env Production

Learn more about apivault env

keys

List, add, reveal, update and delete the encrypted keys in a project.

apivault keysShell
apivault keys list

Learn more about apivault keys

login

Connect this device to your account through a browser approval.

apivault loginShell
apivault login

Learn more about apivault login

logout

Revoke this device's token and sign out.

apivault logoutShell
apivault logout

Learn more about apivault logout

logs

List, filter, stream and inspect a project's audit and request logs.

apivault logsShell
apivault logs --status error --source mcp

Learn more about apivault logs

projects

List your projects and choose which one the current directory uses.

apivault projectsShell
apivault projects list

Learn more about apivault projects

run

Run a command with an environment's secrets injected, without writing them to disk.

apivault runShell
apivault run --env Production -- npm start

Learn more about apivault run

whoami

Show which user or service token the CLI is using and when its token expires.

apivault whoamiShell
apivault whoami

Learn more about apivault whoami

Security

LayerDetail
TransportHTTPS with token-header authentication
Local storageThe CLI uses the OS credential store for the login token and vault keys when available. It falls back to ~/.apivault/secrets.json, with owner-only permissions on macOS and Linux. ~/.apivault/config.json holds non-secret defaults.
Process isolationapivault run injects secrets into the child process without writing a dotenv file.
  • Browser-based pairing — CLI auth uses a one-time browser approval flow. No passwords are typed in the terminal.
  • Dotenv isolation — apivault run temporarily hides local .env files so injected vault secrets take precedence.
  • Keep vault keys out of shell history. Run apivault config set vaultKey to enter the key at a hidden prompt and save it for the project. See Vault keys.
Prefer run over export
Use apivault run to inject secrets into a process instead of writing decrypted values to a .env file on disk. Fewer files means fewer leak paths.

CLI tokens are separate from MCP OAuth tokens — revoking one does not affect the other.