# Deleting an owner

> When a user or a group is deleted, their secrets, their key, and every grant and share made to them go with them.

When you delete a user or a group from the realm, the store removes everything it keeps for them and destroys their
key, so nothing they owned can be opened again, from the live store or from any database backup. There is nothing to
clean up by hand, and nothing anyone else owns is touched.

## Before you begin

- **Who:** a realm administrator who may delete users and groups: `RealmOwner`, or a privilege of your own that
  allows it. See [Delegated administration](/platform/realms/delegated-administration/).
- **Where:** the API. There are no screens yet.
- **First:** the user hands over anything others will need. Once they are deleted, no one can read what they kept.

## How it works

| Deleted | Goes with it |
|---|---|
| A user | every secret in their vault, their key, every grant made to them, every nomination they made or were named in, every one-time share made for them alone, and their sealed vaults with every key wrapped to them (once sealed vaults are in use) |
| A group | every secret in its vault, its key, every grant made to it, and its sealed vaults |

The user or group is deleted first. Clean-up follows the delete at once and is retried until it completes, normally
within minutes.

## Set it up

Nothing to set up: deleting the user or the group is the whole step. For example, deleting `ben`
([Call the API](/develop/api/) shows how to get `$CVYUH_SESSION`):

```sh
curl -X DELETE https://foobar.cvyuh.com/api/v0/am/objects/v1/user/ben \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  -H 'If-Match: "<rev>"'
```

## What users see

- A grantee of the deleted user's secrets finds them gone from `GET …/shared`, and reading one answers `404`.
- A one-time share the deleted user made for someone else stays readable until it is read or expires.
- A user created again with the same user id gets a new, empty vault and a new key.

## Limits and defaults

| Limit | Value |
|---|---|
| Clean-up | follows the delete at once, retried until it completes, normally within minutes |
| Undo | none: a destroyed key can't be brought back |

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| A grant on a group's or the realm's secret stopped opening after a user was deleted | That user was the last to write the secret, and grants on it open from the last writer's key | Someone with the vault's right writes the secret again |
| A grantee still finds a deleted user's secret in `GET …/shared` | Clean-up is still running | Wait a few minutes; it is retried until it completes |

## Audit record

The user's or group's delete is a `DELETED` change record under whoever made it. The destruction of their key is a
`DELETED` change record made by the store. See [Secrets audit trail](/secrets-store/keys-and-protection/audit-trail/).

## Good to know

- **Nothing of anyone else's goes.** A secret goes only when it belongs to the deleted owner, a nomination only when it
  names them, and a one-time share only when they were its one recipient.
- **Their key is destroyed.** Every version of the deleted owner's key is removed. See
  [Crypto-shredding](/secrets-store/keys-and-protection/crypto-shredding/).
- **Grants can pause after a writer is deleted.** If the user who last changed a group's or the realm's secret is
  deleted, grants on that secret stop working until someone writes it again. Write it again after removing a member.
- **Hand over first.** A user who must pass secrets on does so before they leave, with a grant, a one-time share, or
  by writing them into a group's or the realm's vault.

## Related

- [Offboard someone](/secrets-store/guides/offboard-someone/): every step of a departure.
- [Crypto-shredding](/secrets-store/keys-and-protection/crypto-shredding/): why a destroyed key reaches every backup.
