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
string
required
The API endpoint path you’re requesting
string
required
A unique identifier for this request. Must be different for each API call.
number
required
Token issued at time (Unix timestamp)
number
required
Token expiration time (Unix timestamp).
string
required
Your API key identifier
string
required
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