Skip to main content

Overview

The /.well-known/jwks.json endpoint returns the JSON Web Key Set (JWKS) containing public keys used to verify JWT signatures issued by SuperTokens. This endpoint follows the standard JWKS specification (RFC 7517) and is commonly used by applications to validate JWTs. Key Features:
  • Standard JWKS format (RFC 7517)
  • No authentication required (public endpoint)
  • No API version header required
  • App-specific key sets
  • Cache-Control headers for optimal performance
  • Supports multiple signing algorithms

Endpoint

Base URL: http://localhost:3567

Request

Headers

No headers required. This is a public endpoint.

Query Parameters

None.

Request Body

None.

Response

Success Response

Status Code: 200 OK Content-Type: application/json Headers:
Body:
array
required
Array of JSON Web Key objects

JSON Web Key Object

string
required
Key type - typically "RSA" for RSA keys
string
required
Key ID - unique identifier for this key. Used in JWT headers to specify which key signed the token.
string
required
RSA public key modulus (base64url-encoded)
string
required
RSA public key exponent (base64url-encoded)
string
required
Algorithm - signing algorithm used (e.g., "RS256" for RSA with SHA-256)
string
required
Public key use - typically "sig" for signature verification

Error Response

Status Code: 500 Internal Server Error Returned when:
  • Storage query exception occurs
  • Key generation fails
  • Unsupported JWT signing algorithm
  • App or tenant not found

Examples

cURL

Response:

App-Specific Request

Check Cache Headers

Response Headers:

JavaScript (Node.js)

Python

JWT Verification

Using jsonwebtoken (Node.js)

Using PyJWT (Python)

Using jose (Go)

Implementation Details

Key Rotation

SuperTokens uses multiple keys simultaneously to support key rotation:
  • Static keys: Long-lived keys for consistency
  • Dynamic keys: Rotating keys for enhanced security
Both types of keys are included in the JWKS response. Source: View source

Cache Control

The endpoint sets cache headers to optimize performance while ensuring keys stay fresh:
The cache duration is determined by the signing key configuration. Source: View source

App-Specific Keys

Each app in a multitenancy setup has its own set of signing keys. Use app-specific URLs to retrieve the correct keys:

Use Cases

OAuth 2.0 / OpenID Connect Discovery

Include the JWKS URL in your OpenID Connect discovery document:

Verify Access Tokens

API Gateway Integration

Configure your API gateway to use the JWKS endpoint for token validation:

Best Practices

Cache the JWKS response according to the Cache-Control headers to reduce latency and server load.
Always verify the JWT signature using the public keys from this endpoint. Never skip signature verification in production.
Performance:
  • Cache JWKS responses for the duration specified in Cache-Control
  • Implement a background refresh before cache expiration
  • Use connection pooling for repeated requests
Security:
  • Always use HTTPS in production
  • Verify the kid (key ID) matches between JWT header and JWKS
  • Check token expiration and other claims
  • Implement proper error handling for invalid tokens
Multitenancy:
  • Use app-specific JWKS URLs for each app
  • Don’t share keys across security boundaries
  • Update JWKS cache when switching apps

Health Check

Test server connectivity

API Overview

Learn about authentication and error handling

Standards and Specifications

Troubleshooting

Token Verification Fails

  1. Check that the kid in the JWT header matches a key in the JWKS
  2. Verify you’re using the correct JWKS URL for your app
  3. Ensure the JWT algorithm matches the key’s alg field
  4. Check token expiration claims

Keys Not Found

  1. Verify SuperTokens is running: curl http://localhost:3567/hello
  2. Check for storage/database errors in SuperTokens logs
  3. Verify app identifier if using multitenancy
  4. Ensure signing keys are initialized

Cache Issues

  1. Respect Cache-Control headers to avoid stale keys
  2. Implement a cache refresh mechanism
  3. Clear cache after key rotation events
  4. Monitor cache hit rates