Skip to main content
This guide assumes you have already installed Vault. If not, complete the installation first.

Your First Vault Commands

Let’s walk through the essential Vault operations. By the end of this guide, you’ll understand how to store, retrieve, update, and manage key-value data.
1

Add your first key-value pair

Let’s start by storing a simple key-value pair. We’ll add an API key for a fictional service:
vault add api_key "sk-1234567890abcdef"
Expected output:
Adding key: api_key with the value: sk-1234567890abcdef to the vault
Values with spaces must be quoted. For example: vault add greeting "Hello World"
Let’s add a few more entries to work with:
vault add database_url "postgresql://localhost/mydb"
vault add max_connections "100"
vault add app_name "MyApplication"
2

List all keys

Now let’s see what keys we’ve stored in the vault:
vault list
Expected output:
api_key
app_name
database_url
max_connections
Keys are displayed in alphabetical order. If your vault is empty, you’ll see (no keys) instead.
3

Retrieve a value

To get the value associated with a key, use the get command:
vault get api_key
Expected output:
sk-1234567890abcdef
If you try to get a key that doesn’t exist:
vault get nonexistent_key
Expected output:
Key not found
4

Update an existing value

Need to change a value? Use the update command:
vault update max_connections "200"
Expected output:
Updating key: max_connections with the value: 200 in the vault
Verify the update:
vault get max_connections
Expected output:
200
If you try to update a key that doesn’t exist, you’ll see:
Key: nonexistent_key does not exist in db
Use add for new keys and update only for existing ones.
5

Remove a key

When you no longer need a key, remove it from the vault:
vault remove api_key
Expected output:
Removing key: key api_key from vault
Verify the key is gone:
vault list
Expected output:
app_name
database_url
max_connections
Notice that api_key is no longer in the list.

Command Reference

Here’s a quick reference for all Vault commands:

add

vault add <key> <value>
Store a new key-value pair. The key must be unique.

get

vault get <key>
Retrieve the value for a given key.

update

vault update <key> <value>
Update the value of an existing key.

remove

vault remove <key>
Delete a key and its value from the vault.

list

vault list
Display all keys in alphabetical order.

Practical Examples

Storing Configuration

Use Vault to store application configuration that you need across development sessions:
# Store database credentials
vault add db_host "localhost"
vault add db_port "5432"
vault add db_name "development"
vault add db_user "developer"

# Retrieve them later
vault get db_host
vault get db_port

Managing API Keys

Keep track of different API keys for various services:
# Store multiple API keys
vault add github_token "ghp_xxxxxxxxxxxx"
vault add openai_key "sk-xxxxxxxxxxxx"
vault add stripe_key "sk_test_xxxxxxxxxxxx"

# List all keys to see what you have
vault list

Script Integration

Vault is perfect for scripts that need to access stored values:
#!/bin/bash

# Retrieve values from vault
API_KEY=$(vault get api_key)
BASE_URL=$(vault get base_url)

# Use them in your script
curl -H "Authorization: Bearer $API_KEY" "$BASE_URL/api/data"

Updating Configuration

When your configuration changes:
# Update an existing value
vault update db_host "production-server.example.com"

# Verify the change
vault get db_host

Common Patterns

Command Arguments

vault add port 8080
vault add environment production

Error Handling

Vault provides clear feedback when operations fail:
# Trying to add a duplicate key
vault add api_key "new-value"
# Error: SQLite will reject this due to UNIQUE constraint

# Trying to update a non-existent key
vault update missing_key "value"
# Output: Key: missing_key does not exist in db

# Trying to get a non-existent key
vault get missing_key
# Output: Key not found

Tips and Best Practices

Choose clear, consistent naming conventions for your keys:
# Good
vault add aws_access_key "..."
vault add aws_secret_key "..."
vault add aws_region "us-east-1"

# Avoid
vault add key1 "..."
vault add k "..."
Always use quotes for values that contain spaces or special characters:
vault add message "Hello, World!"
vault add json '{"name": "value"}'
Before adding a key, check if it already exists:
vault list | grep api_key
Your vault is stored in a SQLite database. To backup:
cp ~/.kvstore/store.db ~/.kvstore/store.db.backup

What’s Next?

You now know the fundamentals of using Vault! Here are some next steps:

Commands

Detailed documentation for every command

Database Location

Understand where your data is stored

Troubleshooting

Solutions to common problems

Need Help?

If you run into issues:
  1. Check that you’re using the correct command syntax
  2. Verify that .NET 9.0 or later is installed
  3. Ensure you have write permissions to your home directory
  4. Review the installation guide for troubleshooting tips

Build docs developers (and LLMs) love