# Offboard someone

> When a user leaves, take back every grant they were given, remove them from their teams, and let their own secrets go with their account.

When `ben` leaves, he should keep no way into anyone's secrets, and what he kept for himself should go with his
account. As a realm administrator you do this without reading any of his secrets. Taking access back doesn't take
back what he already read, so the last step is changing what he could see.

**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 and changing users and groups), signed in with your session in `$CVYUH_SESSION`
([Call the API](/develop/api/) shows how). Ask the user to hand over anything others will need before you delete them:
with a grant, a one-time share, or by writing it into a group's or the realm's vault.

## Offboard them

<Steps>

1. Take back every grant made to `ben`, in every vault:

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

   The realm answers `200` with `{ "removed": <n> }` under `data`. It lists none of the grants and opens none of the
   secrets.

2. Remove him from each group, so he loses its vault, with the group's current `rev`:

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

3. Delete his account, with its current `rev`:

   ```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>"'
   ```

   Every secret in his vault, his key, every nomination he made or was named in, and every one-time share made for
   him alone go with him. What others own stays.

4. Rotate what he could read. Revoking grants and removing him from groups stops further reads; it doesn't unsee
   values he already read. Treat each of these as exposed and write a new value for it, starting with the most
   sensitive:

   - every secret in the vaults of the groups he was in;
   - every secret in the realm's vault, if he was a realm administrator;
   - every secret he held a grant on, as the `removed` count in step 1 showed. Each owner changes their own; ask
     them, since their grants are listed only to them.

   Change the credential where it is used first (the database, the provider), then write the new value into the
   vault. If someone else last wrote a group's or the realm's secret and is now gone, writing it again also restarts
   every grant on it.

</Steps>

## Check it worked

For a group's or the realm's secret, the secret's grants no longer show a grant to him: for example a `GET` on
`https://foobar.cvyuh.com/api/v0/vault/managed/v1/realm/grants/infra/db-root`. A user's own grants are listed only by
that user.

<Aside type="caution" title="It can't be undone">
  Once his key is destroyed, nothing he kept can be opened again, from the live store or any backup.
</Aside>

## Related

- [Deleting an owner](/secrets-store/vaults/owner-deletion/): everything that goes, and when.
- [Grants](/secrets-store/sharing/grants/): taking one grant back.
