Skip to content
Software capabilities
HashiCorp Vault

List Vault KV v2 keys and folders

List key names under a Vault KV v2 folder with vault kv list or the HTTP metadata endpoint. Grant list on the metadata folder to inventory names without granting access to secret values.

Documentation reviewed · 2 methods with sources

Ways to do it

  1. CLI: vault kv list
  2. API: LIST /v1/{mount}/metadata/{path}
CLI

vault kv list

Use -mount to select the KV v2 engine and list key names below a folder.

Read source: Vault kv list command
Requirements
Vault CLI, VAULT_ADDR, token, and list capability on metadata path.
Limitations
The argument identifies a folder. A folder entry ends in a slash and requires another request to list its children.

Example shell

vault kv list -mount=secret "team/"
API

LIST /v1/{mount}/metadata/{path}

Send LIST to the KV v2 metadata path to retrieve names and child folders.

Read source: Vault KV v2 list secrets API
Requirements
A Vault HTTPS address, a valid X-Vault-Token with list on the metadata folder, and the KV v2 mount name.
Limitations
The list returns every key name in the authorized folder without per-key ACL filtering. Keep sensitive information out of key names.

Example shell

curl --fail --request LIST "$VAULT_ADDR/v1/secret/metadata/team/" -H "X-Vault-Token: $VAULT_TOKEN"