Possible to upload two key values same time via api?

hey folks.
i know you can upload two key values at the same time, per the example on the documentation:

vault kv put kv-v1/dev/config/mongodb url=foo.example.com:35533 db_name=users \
 username=admin password=passw0rd

I was digging around and seeing if this possible using the api? The only difference I was looking to do would be to upload two files instead of inserting values per the above example.
No luck so far.
Was hoping for some suggestions here.
Thx

Hello!

Yes it is possible to do this via the API. The API for v1 accepts a single JSON object as the payload with all of the keys and their values making up that object as seen here: https://www.vaultproject.io/api/secret/kv/kv-v1.html#sample-payload.

The CLI transforms url=foo db_name=users username=admin password=password to

{
  "url": "foo",
  "db_name": "users",
  "username": "admin",
  "password": "password"
}

And just a note, the payload structure and the endpoint you’d use are different if using a v2 kv engine: https://www.vaultproject.io/api/secret/kv/kv-v2.html#sample-payload-1

Cheers,
Matthew

Thanks Meirish. After reading over those links you provided, that makes sense. I tested out a JSON payload and it worked perfectly.
Thank you!

1 Like