# Sealing per owner

> Every value, label and path sealed under its owner's own key, which opens only on its owner's sign-in.

Every secret is encrypted under a key that belongs to its owner. A user's secrets are under that user's own key, a
group's under the group's key, and the realm's under the realm's secrets key. Each key opens only on its holder's
sign-in, so a copy of the database, a backup, or a realm administrator acting as themselves can't open a user's
secrets.

## Before you begin

- **Who:** nothing to call. Sealing happens on every write, for every user.
- **Where:** the API. There are no screens yet.
- **First:** a realm administrator has turned the store on. See [Realm settings](/secrets-store/realm-settings/).

## How it works

| Owner | Sealed under | Opened on |
|---|---|---|
| A user | the user's own key | that user's sign-in |
| A group | the group's own key | a member's sign-in. See [Group keys](/secrets-store/keys-and-protection/group-keys/) |
| The realm | the realm's secrets key | a realm administrator's sign-in |

The store makes each key the first time it is needed: a user's at their first use of the store, a group's when a
member first opens its vault. Each owner also gets a key pair, whose public half is published so others can seal to
it: that is how a [grant](/secrets-store/sharing/grants/)'s copy reaches only its grantee.

| Part of a secret | Stored as |
|---|---|
| Its values, in every version | sealed |
| Its labels (custom metadata) | sealed |
| Its path | a keyed digest, to find it, and sealed, to list it |
| Version numbers, timestamps, deleted and destroyed flags | in the clear |

### What managed vaults trust

Managed vaults trust the realm's sign-in and the platform that holds the keys. A vault opens for whoever signs in as
its owner, and for these besides:

- a nominee let in by [emergency access](/secrets-store/emergency-access/), for a user's personal vault;
- an administrator of a realm above yours, who holds authority over your realm's keys.

For secrets the realm must never be able to open, see [Sealed vaults](/secrets-store/sealed-vaults/).
[Known limitations](/reference/known-limitations/#secrets-store) lists every exception.

## Set it up

There's nothing to set up: every write is sealed. A user's key is made by their first call to the store, such as
reading its settings ([Call the API](/develop/api/) shows how to get `$CVYUH_SESSION`):

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

## When it fails

| Answer | When | What to do |
|---|---|---|
| `503`, "this realm has no secrets key" | The realm's secrets key was destroyed; the realm's vault and one-time shares can't seal or open | See [Crypto-shredding](/secrets-store/keys-and-protection/crypto-shredding/) |
| `404` on a grant or nomination | The user or group named has no key yet | They use the store once; a group's member opens its vault once |

## Limits and defaults

| Limit | Value |
|---|---|
| Keys per owner | one, made at first use; a user's is replaced after a nominee opens their vault |
| Can sealing be turned off | no |

## Audit record

Sealing writes no record of its own. Each write that seals is a change record on the secret; see
[Secrets audit trail](/secrets-store/keys-and-protection/audit-trail/).

## Good to know

- **A value opens for its owner alone.** A sealed value copied into another owner's vault, or under another secret,
  fails to open. It never decrypts as someone else's.
- **Paths never meet.** The same path in two vaults is two separate secrets. The stored secret never holds its path in
  the clear, but the address of each request does, and each request is recorded: see
  [Secrets audit trail](/secrets-store/keys-and-protection/audit-trail/).
- **No key is made in its place.** A realm without its secrets key answers `503`, with the reason, and never seals
  under anything else.
- **Secrets have keys of their own.** The realm's other data is sealed under a different key, so the secrets keys can
  be rotated or destroyed without touching anything else.
- **Written and read only through the Secrets Store API.** No other API writes or opens a secret.

## Related

- [Who can read a secret](/secrets-store/guides/who-can-read-a-secret/): every way a secret can be reached.
- [Group keys](/secrets-store/keys-and-protection/group-keys/): how a group's key works.
- [Key rotation](/secrets-store/keys-and-protection/key-rotation/) and
  [Crypto-shredding](/secrets-store/keys-and-protection/crypto-shredding/): replacing and destroying keys.
