Write custom metadata in key/value v2
Write custom metadata to a kv
v2 secret path.
Assumptions
- You have set up a
kv
v2 plugin. - Your authentication token has
create
andupdate
permissions for thekv
v2 plugin.
Use vault kv metadata put
to set custom
metadata fields for a kv
mount path. Repeat the -custom-metadata
flag for
each key/value metadata entry:
$ vault kv metadata put \ -custom-metadata <key_value_pair> \ -mount <mount_path> \ <secret_path>
For example:
$ vault kv metadata put \ -custom-metadata "use=API keys for different dev environments" \ -custom-metadata "renew-date=2026-11-14" \ -mount shared \ dev/square-api Success! Data written to: shared/metadata/dev/square-api
The custom_metadata
metadata field now includes a map with the two custom
fields:
$ vault kv metadata get -mount shared dev/square-api ======== Metadata Path ========shared/metadata/dev/square-api ========== Metadata ==========Key Value--- -----cas_required falsecreated_time 2024-11-13T21:51:50.898782695Zcurrent_version 9custom_metadata map[use:API keys for different dev environments renew-date:2026-11-14]delete_version_after 0smax_versions 10oldest_version 4updated_time 2024-11-15T03:10:26.749233814Z ====== Version 1 ======Key Value--- -----created_time 2024-11-13T21:51:50.898782695Zdeletion_time n/adestroyed false