- KV v2 is a versioned key-value store that retains previous secret versions.
- KV v1 is a non-versioned key-value store where updates overwrite previous values.
- KV secrets are accessible via the Vault UI, CLI, and API.
- Access is controlled by Vault policies scoped to mount paths and nested paths.
- All KV data is encrypted before being persisted (AES-256).
KV versions: v1 vs v2
Access to KV secrets is available through all three Vault interfaces: the UI, the CLI, and the API. That makes KV useful for both interactive use and automation (Terraform, Jenkins, GitLab CI/CD, etc.).
Design your KV layout before bulk-writing secrets — choose a single large mount with organized paths, or multiple mounts (for example, one per team) to simplify policy boundaries.

Organization and storage model
Secrets are stored as key-value pairs at specific paths under an engine’s mount path. Example layout ideas:- Mount a KV engine at
apps/.- Store secrets for a web app at
apps/aws/prod/. - Under that path you can keep multiple keys (username, password, API key, certificate, etc.).
- Store secrets for a web app at
- Or, have multiple mounts (e.g.,
cloud/,automation/,data/) to isolate teams and simplify policies.
- Single mount with hierarchical paths:
kv/cloud/aws/prod,kv/automation/dev. - Multiple mounts:
cloud/(KV),automation/(KV),data/(KV).

Example paths and stored data
If a KV engine is mounted atapps/, example paths might be:
-
apps/aws/prodcontains:user = dbadminpassword = P@ssw0rdapi = b93md83mdmapw
-
apps/aws/devcontains:cert = ---BEGIN CERTIFICATE...key = ---BEGIN PRIVATE KEY...
apps/aws/prod returns the key-value pairs stored at that path.
Example representation:
Capabilities required to write
When running Vault in development mode (
vault server -dev), Vault automatically enables a KV v2 secrets engine mounted at secret/. In production, you must explicitly enable KV engines where needed.
Enabling the KV Secrets Engine
Enable on any mount path (except protected paths likesys or auth). You can enable multiple KV engines on different mount paths; each acts independently and is governed by policies.
Enabling via the UI:
- In the Vault UI: go to Secrets → Enable new secrets engine → choose “Key/Value” → pick mount path → select KV v1 or v2 and configure options (description, max versions, CAS, etc.).

kv/:
training/:
map[] in Options indicates a KV v1 engine. For KV v2, the Options map contains "version": "2" (or similar).
Enabling and upgrading to KV v2
To enable a mount as KV v2, configure it when enabling or tune an existing mount. To upgrade from KV v1 to KV v2:Upgrading a KV v1 mount to KV v2 is irreversible. You cannot downgrade from v2 back to v1 once versioning is enabled. Plan carefully and ensure your policies and automation accommodate the change.
.../data/...— where secret data is stored and read from via the API..../metadata/...— where metadata operations (list, read metadata, etc.) operate.
cloud/
- Data for
apps/aws/networkis available via API atcloud/data/apps/aws/network. - Metadata is accessible at
cloud/metadata/apps/aws/network.

The Vault CLI hides the
data/ and metadata/ prefixes for you. When using the CLI you can run vault kv get cloud/apps/aws/network without adding the data/ prefix. When working with the API or writing policies for KV v2, you must use data/ and metadata/ prefixes explicitly.KV v2 versioning behavior (common operations)
Versioning gives fine-grained control over secret history and lifecycle.
Concise conceptual workflow:
- Write initial version (v1)
- Update (creates v2)
- Delete latest (soft delete of v2)
- Reading returns no secret data (metadata remains).
- You can undelete v2 to restore it.
- Rollback to v1
- Writing v1’s data again creates v3 (new version) containing the v1 contents.
- Destroy a version (permanent)
destroypermanently removes the specified version data.
Best practices
- Design your KV structure before bulk writing secrets — consistency reduces policy complexity.
- Use multiple mounts for team isolation when teams must not share policies or access paths.
- Use KV v2 when you need version history, soft-deletes, and auditability.
- When writing policies for KV v2, reference
data/andmetadata/paths explicitly. - For automation, prefer the CLI or API and ensure the service account has minimal required capabilities (
create,read,update,delete, etc.).
References and further reading
- HashiCorp Vault Documentation — Key/Value Secrets Engine: https://www.vaultproject.io/docs/secrets/kv
- Vault CLI reference: https://www.vaultproject.io/docs/commands
- Vault Policies: https://www.vaultproject.io/docs/concepts/policies
data/ and metadata/ prefixes in API calls and policies.
We’ll move on to hands-on examples showing CLI and API operations against both KV v1 and KV v2.