Overview
Crown API uses JWT (JSON Web Token) authentication to secure all API endpoints. Every request must include a valid JWT token in the Authorization header.Self-Signed JWT Tokens: Unlike traditional APIs where tokens are issued by the third party, Crown API requires you to generate and sign JWT tokens using your private key on your server-side. This approach provides enhanced security by ensuring only you have control over token creation.
Required Headers
All authenticated requests must include these headers:JWT Structure
Your JWT token must contain the following payload:JWT Payload Fields
The API endpoint path you’re requesting
A unique identifier for this request. Must be different for each API call.
Token issued at time (Unix timestamp)
Token expiration time (Unix timestamp).
Your API key identifier
SHA-256 hash of the request body. Use empty string hash for GET requests.
Signing Your JWT
Sign your JWT using the RS256 algorithm with your private key:Making Authenticated Requests
For comprehensive authentication examples and implementations, check out our authentication examples repository. You’ll find complete working examples in multiple languages including JavaScript, Python, Go, and others.Security Best Practices
- Unique Nonces: Always generate a unique nonce for each request
- Short Expiration: Keep JWT expiration within 50 seconds
- Secure Storage: Store your private key securely
- Body Hashing: Always include the correct body hash, even for empty bodies
Error Responses
Authentication failures will return a401 Unauthorized