Introspect Token - Stytch Docs

Documentation Index

Fetch the complete documentation index at: /docs/llms.txt

Use this file to discover all available pages before exploring further.

Node SDK

Go SDK

Python SDK

Ruby SDK

cURL

const stytch = require('stytch');

const client = new stytch.B2BClient({
  project_id: '${projectId}',
  secret: '${secret}',
  custom_base_url: '${projectDomain}',
});

const params = {
  token: 'eyJ...',
  client_id: '${exampleConnectedAppClientID}',
  client_secret: '${exampleConnectedAppClientSecret}',
  token_type_hint: 'access_token',
};

const options = {
  authorization_check: {
    organization_id: '${organizationId}',
    resource_id: 'documents',
    action: 'create',
  },
};

client.idp
  .introspectTokenNetwork(params, options)
  .then((resp) => {
    console.log(resp);
  })
  .catch((err) => {
    console.log(err);
  });
package main

import (
    "context"
    "log"

"github.com/stytchauth/stytch-go/v16/stytch/b2b/b2bstytchapi"
    "github.com/stytchauth/stytch-go/v16/stytch/b2b/idp"
)

func main() {
    client, err := b2bstytchapi.NewClient(
        "${projectId}",
        "${secret}",
        b2bstytchapi.WithBaseURI("${projectDomain}"),
    )
    if err != nil {
        log.Fatalf("error instantiating client: %v", err)
    }

_, err = client.IDP.IntrospectTokenNetwork(context.Background(), &idp.IntrospectTokenNetworkParams{
        Token:        "eyJ...",
        ClientID:     "${exampleConnectedAppClientID}",
        ClientSecret: "${exampleConnectedAppClientSecret}",
    })
    if err != nil {
        log.Fatalf("error in method call: %v", err)
    }
}
from stytch import B2BClient
from stytch.b2b.models.sessions import AuthorizationCheck

client = B2BClient(
    project_id="${projectId}",
    secret="${secret}",
    custom_base_url="${projectDomain}",
)

resp = client.idp.introspect_token_network(
    token="eyJ...",
    client_id="${exampleConnectedAppClientID}",
    client_secret="${exampleConnectedAppClientSecret}",
    token_type_hint="access_token",
    authorization_check=AuthorizationCheck(
      organization_id='${organizationId}',
      resource_id='documents',
      action='create'
    ),
)

print(resp)
require 'stytch'

client = StytchB2B::Client.new(
  project_id: '${projectId}',
  secret: '${secret}',
  custom_base_url: '${projectDomain}',
)

resp = client.idp.introspect_token_network(
    token="eyJ...",
)

print(resp)
curl --request POST \
  --url https://${projectDomain}/v1/oauth2/introspect \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'client_id=${exampleConnectedAppClientID} \
    &client_secret=${exampleConnectedAppClientSecret} \
    &token=eyJ...'

200

200 Inactive Token

404

429

500

{
  "active": true,
  "aud": ["PROJECT_ID"],
  "client_id": "connected-app-test-d731954d-dab3-4a2b-bdee-07f3ad1be888",
  "exp": 1738848103,
  "iat": 1738844503,
  "iss": "https://${projectDomain}",
  "scope": "openid email profile",
  "sub": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "token_type": "access_token",
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "status_code": 200
}
{
  "active": false,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "status_code": 200
}
{
  "status_code": 404,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "error_type": "idp_client_not_found",
  "error_message": "The IDP client requested could not be found.",
  "error_url": "https://stytch.com/docs/api/errors/404"
}
{
  "status_code": 429,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "error_type": "too_many_requests",
  "error_message": "Too many requests have been made.",
  "error_url": "https://stytch.com/docs/api/errors/429"
}
{
  "status_code": 500,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "error_type": "internal_server_error",
  "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
  "error_url": "https://stytch.com/docs/api/errors/500"
}

Examine and introspect a token for the given Connected Apps client. All standard OIDC claims, as well as custom claims, will be returned. The active status can be used to determine if the token is active. This endpoint supports both access tokens and refresh tokens. This endpoint is an RFC-7662 compliant token introspection endpoint.

We recommend using the Custom Domain whenever possible. For backwards compatibility reasons, this endpoint is also available at https://test.stytch.com/v1/public/${projectId}/oauth2/introspect.

Body

token

token_type_hint

client_id

client_secret

Response

active

scope

client_id

token_type

exp

iat

sub

iss

aud

request_id

status_code