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.
npm install -g apivault
Or run it on demand without a global install:
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.
npm install -g apivault@latest
Checking the version
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:
Authorize your terminal
Connect the CLI to your account through browser approval:
Sign inShellapivault login
Link this directory to a project
Bind the repository to the project whose keys it uses. Find the ID with
apivault projects list.Link the projectShellapivault link <id>
Set a default environment (optional)
Save the environment so you don't have to pass
--envon every run:Set the default environmentShellapivault config set run.env Development
Inject secrets and start your app
Start the dev serverShellapivault 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.
apivault whoami
Run the build with the project's Production secrets.
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 config list
Learn more about apivault config
env
Write an environment's secrets to a dotenv file, or restore files hidden by run.
apivault env export --env Production
keys
List, add, reveal, update and delete the encrypted keys in a project.
apivault keys list
Learn more about apivault keys
login
Connect this device to your account through a browser approval.
apivault login
Learn more about apivault login
logout
Revoke this device's token and sign out.
apivault logout
Learn more about apivault logout
logs
List, filter, stream and inspect a project's audit and request logs.
apivault logs --status error --source mcp
Learn more about apivault logs
projects
List your projects and choose which one the current directory uses.
apivault projects list
Learn more about apivault projects
run
Run a command with an environment's secrets injected, without writing them to disk.
apivault run --env Production -- npm start
whoami
Show which user or service token the CLI is using and when its token expires.
apivault whoami
Security
| Layer | Detail |
|---|---|
| Transport | HTTPS with token-header authentication |
| Local storage | The 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 isolation | apivault 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 runtemporarily hides local.envfiles so injected vault secrets take precedence. - Keep vault keys out of shell history. Run
apivault config set vaultKeyto enter the key at a hidden prompt and save it for the project. See Vault keys.
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.