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
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:
array
required
Array of JSON Web Key objects
JSON Web Key Object
string
required
Key type - typically
"RSA" for RSA keysstring
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 verificationError 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
App-Specific Request
Check Cache 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
Cache Control
The endpoint sets cache headers to optimize performance while ensuring keys stay fresh: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
Performance:- Cache JWKS responses for the duration specified in Cache-Control
- Implement a background refresh before cache expiration
- Use connection pooling for repeated requests
- 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
- Use app-specific JWKS URLs for each app
- Don’t share keys across security boundaries
- Update JWKS cache when switching apps
Related Endpoints
Health Check
Test server connectivity
API Overview
Learn about authentication and error handling
Standards and Specifications
- RFC 7517 - JSON Web Key (JWK)
- RFC 7518 - JSON Web Algorithms (JWA)
- RFC 7519 - JSON Web Token (JWT)
- OpenID Connect Discovery
Troubleshooting
Token Verification Fails
- Check that the
kidin the JWT header matches a key in the JWKS - Verify you’re using the correct JWKS URL for your app
- Ensure the JWT algorithm matches the key’s
algfield - Check token expiration claims
Keys Not Found
- Verify SuperTokens is running:
curl http://localhost:3567/hello - Check for storage/database errors in SuperTokens logs
- Verify app identifier if using multitenancy
- Ensure signing keys are initialized
Cache Issues
- Respect Cache-Control headers to avoid stale keys
- Implement a cache refresh mechanism
- Clear cache after key rotation events
- Monitor cache hit rates