# Let users remove agents

> Each user's AI agents page lists the agents allowed to act for them, and removing one ends its access in their name at once.

Users stay in control of which agents act for them, without asking a realm administrator. On their **AI Agents** page
they see each agent allowed to act for them, with what it may do and until when, and stop any of them. There's
nothing for you to set: the page is in the dashboard for every user.

**Before you start:**

- **Who can do it:** any signed-in user, for agents acting for them. A realm administrator can do it for any user (see
  [As a realm administrator](#as-a-realm-administrator)).
- **Where:** the user's own **AI Agents** page in the dashboard, or the API with their own session.
- **What you need:** an agent has been allowed to act for the user (see
  [Let an agent act for a user](../agent-acts-for-a-person/)).

## Remove an agent

<Steps>

1. The user opens **AI Agents** in the dashboard. In the API, with the user's own session in `$CVYUH_SESSION`
   ([Call the API](/develop/api/)):

   ```sh
   curl https://foobar.cvyuh.com/api/v0/am/me/v1/oauth2/agents \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
   ```

2. They choose **Stop** on the agent. In the API, name it by the `agent` id the list answered:

   ```sh
   curl -X DELETE https://foobar.cvyuh.com/api/v0/am/me/v1/oauth2/agents/6f1c2a9e-4b7d-4e3a-9c51-2d8f0b7a1e44 \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
   ```

   The realm answers `204`.

</Steps>

## Check it worked

- **Its tokens in the user's name stop at once**: at the realm, at introspection and at every gateway, impersonation
  tokens included.
- **The delegation is deleted**, so no new token in the user's name is issued to that agent.
- **The agent's own access is untouched.** Tokens on its own account still work; to stop the agent itself, see
  [Stop an agent](../stop-an-agent/).

The removal is on the user's trail as `AGENT_TAKEN_BACK`.

## As a realm administrator

You remove a delegation by deleting the agent's `actsFor` link to the user:

```sh
curl -X DELETE https://foobar.cvyuh.com/api/v0/am/objects/v1/agent/invoice-agent/relationships/actsFor/maya \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

## Undo it

A removed delegation is deleted. To let the agent act for the user again, a realm administrator writes a new
`actsFor` link, as in [Let an agent act for a user](../agent-acts-for-a-person/).

## Related

- [Token exchange](../../../applications/tokens/token-exchange/): how an agent acts for a user.
- [Revoke tokens](../../../applications/revoke-access/revocation/): how its tokens are revoked.
- [Let users remove apps they allowed](../../../../customer-identity/guides/people-remove-apps/): the same control for apps.
