Authentication
CHRT uses API keys to authenticate requests. Your API keys carry many privileges, so be sure to keep them secure and never share them in publicly accessible areas such as GitHub, client-side code, and so forth.API Key Types
Public Keys
chrt_pk_[env][team][random]
- Safe for browser/mobile use
- Restricted by origin domains
- Limited scopes available
- Cannot access sensitive operations
Secret Keys
chrt_sk_[env][team][random]
- Server-to-server communication only
- Full access to all scopes
- Can perform administrative operations
- Must be kept confidential
Environments
All API keys are scoped to specific environments:- Test Environment (
test): For development and testing - Live Environment (
live): For production use
Authentication Methods
Bearer Token (Recommended)
Include your API key in theAuthorization header:
API Key Header
Alternatively, use theX-CHRT-API-Key header:
Scopes
API keys can be restricted to specific scopes for security:| Scope | Description | Key Types |
|---|---|---|
enc.tiles:read | Access chart tile imagery | Public, Secret |
enc.mbtiles:download | Download offline chart packages | Secret only |
interact.identify:read | Identify chart features by location | Public, Secret |
features.search:read | Search chart features and metadata | Public, Secret |
query.spatial:read | Perform spatial queries on chart data | Public, Secret |
keys.manage | Create and manage API keys | Secret only |
team.manage | Manage team members and settings | Secret only |
Restrictions
Domain Restrictions (Public Keys)
Public keys can be restricted to specific domains for security:IP Allowlist
Restrict API key usage to specific IP addresses or CIDR blocks:Rate Limits
API keys have built-in rate limiting to prevent abuse:- Free Plan: 1,000 requests per month
- Starter Plan: 10,000 requests per month
- Pro Plan: 100,000 requests per month
- Enterprise: Custom limits
Security Best Practices
Key Management
Key Management
- Generate separate keys for different environments
- Use descriptive names to identify key purposes
- Rotate keys regularly (we recommend every 90 days)
- Revoke unused or compromised keys immediately
Public Key Safety
Public Key Safety
- Always set domain restrictions for public keys
- Use minimal required scopes
- Monitor usage for unexpected patterns
- Consider IP restrictions for known client IPs
Secret Key Protection
Secret Key Protection
- Never expose secret keys in client-side code
- Store in environment variables or secure vaults
- Use HTTPS for all API requests
- Implement proper error handling to avoid key leakage
Error Responses
Authentication errors return specific status codes:| Status | Error | Description |
|---|---|---|
401 | invalid_key | API key is malformed or doesn’t exist |
403 | insufficient_scope | Key lacks required permissions |
403 | domain_restricted | Request origin not in allowlist |
403 | ip_restricted | Client IP not in allowlist |
429 | rate_limited | Too many requests |
