Authentication Methods
Autumn supports two types of API keys for authentication:- Secret Keys - Full API access for server-side operations
- Publishable Keys - Limited access for client-side operations
Secret Keys
Secret keys provide full access to your Autumn API and should only be used in server-side code. Never expose secret keys in client-side code or public repositories.Key Formats
Secret keys follow these formats based on environment:- Test/Sandbox:
am_sk_test_... - Live/Production:
am_sk_live_...
am_ prefix.
Using Secret Keys
Include your secret key in theAuthorization header as a Bearer token:
Example with Different Languages
Publishable Keys
Publishable keys provide limited, read-only access to specific endpoints and can be safely used in client-side code.Key Formats
- Test/Sandbox:
am_pk_test_... - Live/Production:
am_pk_live_...
Allowed Endpoints
Publishable keys can only access these endpoints:| Method | Endpoint | Description |
|---|---|---|
GET | /v1/products | List products |
POST | /v1/entitled | Check entitlements |
POST | /v1/check | Check feature access |
GET | /v1/customers/:customer_id | Get customer details |
Using Publishable Keys
Dashboard Authentication
Requests from the Autumn dashboard use Better Auth session-based authentication instead of API keys. These requests include thex-client-type: dashboard header.
Environment-Based Keys
Autumn automatically determines the environment (sandbox or live) based on your API key:- Keys starting with
am_sk_test_oram_pk_test_→ Sandbox environment - Keys starting with
am_sk_live_oram_pk_live_→ Live environment
Authentication Errors
Common authentication errors you may encounter:| Error Code | Status | Description |
|---|---|---|
no_secret_key | 401 | No Authorization header provided |
invalid_secret_key | 401 | API key is invalid or malformed |
invalid_auth_header | 401 | Authorization header format is incorrect |
no_publishable_key | 401 | Publishable key missing |
invalid_publishable_key | 401 | Publishable key is invalid |
endpoint_not_public | 401 | Endpoint not accessible with publishable key |
failed_to_verify_secret_key | 401 | Could not verify the secret key |
failed_to_verify_publishable_key | 401 | Could not verify the publishable key |
Example Authentication Error
Best Practices
Keep Secret Keys Secure
Keep Secret Keys Secure
- Never commit secret keys to version control
- Store keys in environment variables
- Use different keys for different environments
- Rotate keys regularly
- Never expose keys in client-side code or public repositories
Use Appropriate Key Types
Use Appropriate Key Types
- Use secret keys for server-side operations
- Use publishable keys for client-side, read-only operations
- Use test keys during development and testing
- Use live keys only in production
Handle Authentication Errors
Handle Authentication Errors
- Implement proper error handling for 401 responses
- Log authentication failures for security monitoring
- Don’t expose detailed authentication errors to end users
- Implement retry logic with exponential backoff