Skip to content
Secrets StoreMarkdown

Store a secret

Keep a password or an API key in your own vault, read it back, and read any earlier version of it.

API

You have a password you’d rather not keep in a text file. Stored in your own vault, it is sealed under your own key, so no one else acting as themselves can read it, a realm administrator included, and every change you make is kept as a version you can go back to. Known limitations lists the exceptions, such as someone who can sign in as you.

Before you start: a realm administrator has turned the store on, and you are signed in to the realm with your session in $CVYUH_SESSION (Call the API shows how).

  1. Write the secret under a path you choose, such as web/github:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "data": { "user": "maya", "password": "<password>" } }'

    The realm answers 200 with the new version’s metadata. This is version 1. A 409 means the store isn’t on yet; ask a realm administrator to turn it on.

  2. Read it back:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

    The answer carries the values under data.data and the version’s metadata under data.metadata.

  3. Change one value. A PATCH merges what you send into the latest version, as a new version:

    Terminal window
    curl -X PATCH https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "data": { "password": "<new password>" } }'

    A value sent as null is removed.

Read the first version again:

Terminal window
curl "https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github?version=1" \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

It still holds the original password: a path keeps its last 10 versions unless you or the realm set another limit.

Delete the latest version with a DELETE on https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github, or the whole secret with a DELETE on …/me/metadata/web/github. See Take back a change.