# Cut off a lost device

> Revoke a lost or stolen device so it can reach nothing, then restore it if it's found or remove it if it isn't.

Maya reports her laptop stolen. You want `maya-laptop` cut off from the realm now, before you know whether it'll turn
up. Revoking it closes its connection everywhere at once, and leaves you free to restore it later or remove it for
good. It doesn't lock or wipe the laptop.

## Before you start

- You hold `MODIFY` on the realm's endpoint settings (`RealmOwner` has it; see
  [Who can call](../../api/#who-can-call)), with your session in `$CVYUH_SESSION`
  ([Call the API](../../../develop/api/)). It's all done through the API.
- You know the device's name, here `maya-laptop`.

## Revoke it

<Steps>

1. **Find the device.** List the realm's devices and pick the one whose `uid` is `maya-laptop`:

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

   Keep its `id`, the device id. If you don't know the name: when Maya has approved the laptop for AI governance,
   her user id is in its `users`, which holds only the users who approved it, not everyone who signs in.

2. **Revoke it**, with a reason you'll recognize later:

   ```sh
   curl -X PUT https://foobar.cvyuh.com/api/v0/endpoint/ppm/v1/<device id>/revocation \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{"reason": "Reported stolen"}'
   ```

   The realm answers `204`. Every stream the device holds is closed, and it can open no new one.

3. **Deal with Maya's own access separately.** Revoking the device doesn't end her sessions elsewhere. If her
   credentials were on the laptop too, revoke her tokens as well; see the gateway's
   [Revocation](../../../gateway/revocation/).

</Steps>

## Check it worked

Ask whether it's connected:

```sh
curl https://foobar.cvyuh.com/api/v0/endpoint/ppm/v1/<device id>/connected \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

It answers `{ "connected": false }`. Read the record (the same address without `/connected`): its `status` is
`revoked`, with you in `revokedBy`.

## Undo it

If the laptop is found, restore it, and it reconnects on its own:

```sh
curl -X DELETE https://foobar.cvyuh.com/api/v0/endpoint/ppm/v1/<device id>/revocation \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

If it's gone for good, remove it instead, so every part of the realm forgets it:

```sh
curl -X DELETE https://foobar.cvyuh.com/api/v0/endpoint/ppm/v1/<device id> \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

The realm answers `202`; reading the record answers `404` once the removal has finished.

<Aside type="note" title="Removal is final">
  A removed device can come back only by enrolling again with a new token. Neither revoking nor removing wipes the
  laptop's data.
</Aside>

## Related

- [Device revocation](../../revoke-and-remove/revocation/): what a revoke does, and what it doesn't.
- [Device removal](../../revoke-and-remove/removal/): what each part forgets.
- [Handle an alert on a device](../../../detection-response/guides/handle-an-alert/): block an address or disable a
  local account instead, while the device stays connected.
