# Subkeys

> See the names inside a secret without its values, to check what it holds before anyone opens it.

Subkeys show the shape of a secret: the names of its values, with every value left out. A tool can check that a
secret has the fields it expects, such as `user` and `password`, without reading the password itself.

## Before you begin

- **Who:** anyone who may view the secret: every right in its vault, or a `view` grant.
- **Where:** the API. There are no screens yet.
- **First:** the secret has a live version.

## How it works

A `GET` on `https://foobar.cvyuh.com/api/v0/vault/managed/v1/<vault>/subkeys/<path>` answers the latest version's
names, every value replaced by `null`, with the version's metadata. Add `?version=<n>` for an older version, and
`?depth=<d>` to stop after `<d>` levels of nested objects. `0`, the default, goes all the way down.

## Set it up

There's nothing to set up. Read the names in `web/github` ([Call the API](/develop/api/) shows how to get
`$CVYUH_SESSION`):

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

```json
{ "data": { "subkeys": { "user": null, "password": null }, "metadata": { "version": 3, "…": "…" } } }
```

## When it fails

| Answer | When | What to do |
|---|---|---|
| `404` | The path or version isn't there, the version is deleted or destroyed, or, in a personal vault, you have no access | Ask for a live version |
| `403` | A `use` grant, or no right in a group's or the realm's vault | Ask for `view` |

## Limits and defaults

| Limit | Default |
|---|---|
| `depth` | `0`, all the way down |
| `version` | the latest |

## Audit record

A subkeys read changes nothing, so it writes no change record; it is an `ACCESS` record under the reader. See
[Secrets audit trail](/secrets-store/keys-and-protection/audit-trail/).

## Good to know

- **The version must be live.** Asking for a deleted or destroyed version answers `404`.
- **It needs `view`.** Someone with only a `use` grant can't read a secret's subkeys.
- **Labels are left out.** The metadata in the answer carries no `custom_metadata`.

## Related

- [Organize and find secrets](/secrets-store/guides/organize-and-find-secrets/): listing and subkeys together.
- [Metadata](/secrets-store/secrets/metadata/): a secret's history and settings.
