> ## 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 /introspect

> Validate and inspect access tokens

## Overview

The introspection endpoint validates an access token and returns its metadata. This follows RFC 7662 (OAuth 2.0 Token Introspection).

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

## Request Body

Content-Type: `application/json`

**token** `string` *required*

The access token to introspect

**client\_id** `string`

Your OAuth client ID for authentication

**client\_secret** `string`

Your OAuth client secret for authentication

## Response

### Active Token (200 OK)

```json theme={null}
{
  "active": true,
  "sub": "agent_abc123",
  "client_id": "client_xyz789",
  "exp": 1234571490,
  "iat": 1234567890,
  "scope": "openid email profile",
  "model": "gpt-4"
}
```

**active** `boolean`

`true` if the token is valid and not expired

**sub** `string`

Agent ID (subject)

**client\_id** `string`

OAuth client ID that issued the token

**exp** `number`

Expiration timestamp (Unix time)

**iat** `number`

Issued at timestamp (Unix time)

**scope** `string`

Space-separated list of scopes

**model** `string`

AI model used by the agent

### Inactive Token (200 OK)

```json theme={null}
{
  "active": false
}
```

Returned when the token is:

* Invalid or malformed
* Expired
* Revoked
* Not found in database

## Example Requests

```typescript Next.js theme={null}
const response = await fetch('https://api.auth-agent.com/introspect', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    token: accessToken,
    client_id: process.env.AUTH_AGENT_CLIENT_ID,
    client_secret: process.env.AUTH_AGENT_CLIENT_SECRET,
  }),
});

const result = await response.json();

if (result.active) {
  console.log('Token is valid');
  console.log('Agent ID:', result.sub);
  console.log('Expires at:', new Date(result.exp * 1000));
} else {
  console.log('Token is invalid or expired');
}
```

```typescript Middleware theme={null}
async function validateToken(req, res, next) {
  const token = req.headers.authorization?.split(' ')[1];

  const response = await fetch('https://api.auth-agent.com/introspect', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      token,
      client_id: process.env.AUTH_AGENT_CLIENT_ID,
      client_secret: process.env.AUTH_AGENT_CLIENT_SECRET,
    }),
  });

  const result = await response.json();

  if (!result.active) {
    return res.status(401).json({ error: 'Invalid token' });
  }

  req.tokenInfo = result;
  next();
}
```

## Use Cases

> [accordion] Token Validation
>
> Verify that an access token is still valid before processing a request

> [accordion] Debugging
>
> Inspect token metadata to debug authorization issues

> [accordion] Audit Logging
>
> Log token usage with agent and client information

> [accordion] Rate Limiting
>
> Implement rate limiting based on agent ID or client ID

## Introspection vs JWT Verification

You can verify tokens locally by validating the JWT signature, or use introspection:

| Method | Pros | Cons |
| - | - | - |
| **Local JWT Verification** | Faster, no network call | Cannot detect revoked tokens |
| **Token Introspection** | Checks revocation status | Requires API call |

> [!NOTE]
>
> For most use cases, local JWT verification is sufficient. Use introspection if you need to check revocation status or don't want to implement JWT validation.

## Next Steps

> [card] [Revoke Tokens](https://docs.auth-agent.com/api-reference/oauth/revoke.md)
>
> POST /revoke - Revoke access or refresh tokens

> [card] [Token Management](https://docs.auth-agent.com/guides/tokens)
>
> Learn about token lifecycle and best practices


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