# Keep the organization's secrets

> Keep shared infrastructure credentials in the realm's own vault, which outlives any one user's account.

Some secrets belong to the organization, not to any one user: infrastructure credentials, signing material for
partners. Kept in the realm's vault, they outlive any account. Every realm administrator can reach them, and no one
else can unless an administrator grants it.

**Before you start:** you are a realm administrator (a member of a group holding `RealmOwner`, or a privilege of your
own that allows `MODIFY` on secrets), the store is on, and you are signed in with your session in `$CVYUH_SESSION`
([Call the API](/develop/api/) shows how). The `engineering` group has had a member open its vault once, so a grant can
be sealed to it.

## Keep a secret for the organization

<Steps>

1. Write it into the realm's vault:

   ```sh
   curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/realm/data/infra/db-root \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "data": { "user": "root", "password": "<password>" } }'
   ```

2. List the vault:

   ```sh
   curl "https://foobar.cvyuh.com/api/v0/vault/managed/v1/realm/metadata?list=true" \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
   ```

3. Let the `engineering` team use it, without seeing anything else:

   ```sh
   curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/realm/grants/infra/db-root \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "group": "engineering", "access": "use" }'
   ```

   A member of the group reads it at `https://foobar.cvyuh.com/api/v0/vault/managed/v1/realm/data/infra/db-root`.

</Steps>

## Check it worked

Anyone who isn't a realm administrator and holds no grant is refused (`403`). A `GET` on
`https://foobar.cvyuh.com/api/v0/vault/managed/v1/realm/grants/infra/db-root` lists the grants on it.

If the grant answers `404`, no member of `engineering` has opened the group's vault yet: one of them lists it once,
then grant again.

## Undo it

Take a grant back:

```sh
curl -X DELETE https://foobar.cvyuh.com/api/v0/vault/managed/v1/realm/grants/infra/db-root/<edgeId> \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

The grant's copy opens from the key of whoever last wrote the secret. If that administrator is later deleted, the
group's reads stop until another administrator writes the secret again.

## Related

- [Vaults](/secrets-store/vaults/): the realm's vault and who reaches it.
- [Grants](/secrets-store/sharing/grants/): `view` and `use`.
- [Rotate the secrets key](/secrets-store/guides/rotate-the-secrets-key/): the key that seals the realm's vault.
