> ## Documentation Index
> Fetch the complete documentation index at: https://docs.auth-agent.com/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /revoke

> Revoke access or refresh tokens

## Overview

The revocation endpoint allows clients to revoke access or refresh tokens. This follows RFC 7009 (OAuth 2.0 Token Revocation).

```
POST https://api.auth-agent.com/revoke
```

## Request Body

Content-Type: `application/json`

**token** `string` *required*

The access or refresh token to revoke

**client\_id** `string` *required*

Your OAuth client ID

**client\_secret** `string` *required*

Your OAuth client secret

## Response

### Success (200 OK)

```json theme={null}
{
  "revoked": true
}
```

The endpoint returns success even if the token was already revoked or doesn't exist, following RFC 7009 security recommendations.

### Error (401 Unauthorized)

```json theme={null}
{
  "error": "invalid_client",
  "error_description": "Invalid client credentials"
}
```

## Example Requests

```typescript Revoke Refresh Token theme={null}
// Revoke refresh token (also revokes associated access token)
await fetch('https://api.auth-agent.com/revoke', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    token: refreshToken,
    client_id: process.env.AUTH_AGENT_CLIENT_ID,
    client_secret: process.env.AUTH_AGENT_CLIENT_SECRET,
  }),
});

// Clear stored tokens
delete req.session.tokens;
```

```typescript Logout Handler theme={null}
app.post('/api/auth/logout', async (req, res) => {
  const { refresh_token } = req.session.tokens;

  // Revoke the refresh token
  await fetch('https://api.auth-agent.com/revoke', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      token: refresh_token,
      client_id: process.env.AUTH_AGENT_CLIENT_ID,
      client_secret: process.env.AUTH_AGENT_CLIENT_SECRET,
    }),
  });

  // Clear session
  req.session.destroy();

  res.json({ success: true });
});
```

```python Flask theme={null}
@app.route('/api/auth/logout', methods=['POST'])
def logout():
    refresh_token = session['tokens']['refresh_token']

    # Revoke the refresh token
    requests.post(
        'https://api.auth-agent.com/revoke',
        json={
            'token': refresh_token,
            'client_id': os.environ['AUTH_AGENT_CLIENT_ID'],
            'client_secret': os.environ['AUTH_AGENT_CLIENT_SECRET'],
        }
    )

    # Clear session
    session.clear()

    return jsonify({'success': True})
```

## Revocation Behavior

> [accordion] Revoking Refresh Tokens
>
> When you revoke a refresh token, the associated access token is also revoked. This ensures complete session termination.

> [accordion] Revoking Access Tokens
>
> When you revoke an access token, only that specific token is invalidated. The refresh token remains valid.

> [accordion] Idempotent Operation
>
> Calling revoke on an already-revoked token returns success. This is intentional for security reasons per RFC 7009.

> [accordion] Token Family Revocation
>
> Due to refresh token rotation, revoking any token in a refresh chain does not automatically revoke other tokens in that family. Each token must be explicitly revoked.

## Use Cases

> [card] User Logout
>
> Revoke tokens when a user logs out to invalidate their session

> [card] Security Incident
>
> Immediately revoke tokens if a security breach is detected

> [card] Token Cleanup
>
> Revoke old tokens during token refresh or session cleanup

> [card] Account Deletion
>
> Revoke all tokens when an account is deleted or disabled

## Security Considerations

> [!WARNING]
>
> Always revoke refresh tokens during logout. Revoking only the access token leaves the session partially active.

> [!NOTE]
>
> Client authentication is required to prevent unauthorized token revocation.

## Next Steps

> [card] [Token Lifecycle](https://docs.auth-agent.com/guides/tokens)
>
> Learn about token expiration and management

> [card] [Security Best Practices](https://docs.auth-agent.com/guides/security.md)
>
> Implement secure token handling


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.