# Revoke tokens

> A client revokes a token it no longer needs, and every other way access ends across the realm reaches the same places.

A client posts a token it holds to the realm's revocation endpoint, for example at sign-out, and the token is
revoked. Revoking a refresh token revokes its whole family, with every access token issued under it. Revoking an
access token also revokes every token exchanged from it through [token exchange](../../tokens/token-exchange/).

Revocation is one of several ways access ends, and all of them reach the realm,
[introspection](../introspection/), [status lists](../status-lists/) and the gateway alike:

| Withdrawn | By | Ends |
|---|---|---|
| One token | The client, at the revocation endpoint | That token, and every token exchanged from it |
| A refresh family | The client, or a reused refresh token (with rotation) | Every token from one sign-in |
| A session | Sign-out, or a timeout | Every online grant from it |
| A client grant | The user, on Authorized Apps | That app's tokens for that user |
| A delegation | The user, on AI Agents | That agent's tokens in their name |
| An agent | A quarantine or kill | Its tokens, and its children's |
| A user's credentials | A partner's security signal | Everything issued to them before that moment |
| A client | Setting it inactive | All its tokens |

## Before you begin

- **Who can do it:** a client revokes its own tokens, with its own credentials; no administrator right is involved.
  To end everything a user holds, a realm administrator ends their sessions instead
  ([Session management](../../../authentication/session-management/)).
- **Where:** the client calls `https://foobar.cvyuh.com/oauth2/revoke`. A user takes back an app on their
  **Authorized Apps** page in the dashboard.
- **First:** nothing to set.

## How it works

The client authenticates as it does at the token endpoint (a public client sends only its `client_id`), and posts
the token:

```sh
curl https://foobar.cvyuh.com/oauth2/revoke \
  -d token=8xLOxBtZp8 \
  -d token_type_hint=refresh_token \
  -d client_id=orders-web
```

The answer is `200` with an empty body.

`token_type_hint` only orders the search: `refresh_token` looks among refresh tokens first, and any other hint, or
none, looks among access tokens first. A wrong hint still finds the token.

**A held request is canceled here too.** An agent's client whose request waits for its owner
([agent guardrails](../../../../gateway/guardrails/agent-guardrails/#or-the-request-waits-for-the-owner)) cancels
it by revoking its deferral code, with `token_type_hint=urn:ietf:params:oauth:token-type:deferral-code`. A token
already collected for that code stays valid. While the realm offers the deferred grant, discovery lists this hint in
`revocation_endpoint_token_type_values_supported`.

## Set it up

Nothing to set. The client posts to `https://foobar.cvyuh.com/oauth2/revoke`, which discovery publishes as
`revocation_endpoint`. A browser app may call it from its own page: see [browser apps](../../single-sign-on/browser-apps/).

## Good to know

- **The caller authenticates first.** A caller that doesn't is refused before any token is looked at.
- **A client may revoke only its own tokens.** Another client's is refused `unauthorized_client`, and stays valid.
- **An unknown or expired token is answered `200`**, and nothing changes.
- **A revoked access token stays revoked** until its `exp` plus the realm's clock tolerance (`clockSkewSecs`), so
  it never reads active again.

## Limits and defaults

| Setting or limit | Default | Range |
|---|---|---|
| How long a revocation is kept | the token's `exp` plus `clockSkewSecs` (60) | `clockSkewSecs` 0 to 300 |
| How fast it takes effect | at once at the realm and in introspection; at the gateway and in status lists within seconds | fixed |
| Who may revoke a token | the client it was issued to | fixed |

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| `200`, but the token still works at your API | Your API checks signatures only, and the token is still within its `exp` | Introspect, read the [status list](../status-lists/), or put the API behind the gateway |
| `unauthorized_client` | The token was issued to another client | Revoke from the client that holds it, or end the user's session |
| `invalid_client` | The caller didn't authenticate as it does at the token endpoint | Send its credentials, or `client_id` for a public client |

## Audit record

Every revocation is a `TOKEN_REVOKED` record, whatever the realm's settings: under the token's user or agent, naming
the client and the kind of token, or under the client for a deferral code. A user taking back an app or an agent is
`APP_TAKEN_BACK` or `AGENT_TAKEN_BACK`. See them in **Audit → Authentication**, or on the user's trail
([Read a user's or agent's trail](/audit-reports/audit-trail/read-a-trail/)).

## Reference

### Errors

| Error | When |
|---|---|
| `invalid_client` | The caller doesn't authenticate |
| `invalid_request` | No `token` is sent, or a parameter is sent twice |
| `unauthorized_client` | The token was issued to another client |

## Related

- [Call the API](../../../../develop/api/): the conventions every call follows.
- [Apps and agents](../../../../develop/apps-and-agents/): every endpoint apps and agents call.
- [Revoke a token](../../../../gateway/guides/revoke-a-token/): the task, start to finish.
- [Let users remove apps they allowed](../../../../customer-identity/guides/people-remove-apps/): the Authorized Apps page.
- [Status lists](../status-lists/): tell APIs that check tokens offline about a revocation.
- [Refresh tokens](../../single-sign-on/refresh-tokens/): families, and how a reused one is caught.
- [Logout](../../single-sign-on/logout/): what ends with a session.
