API Key Format
API keys are passed via theazen-api-key header:
Authentication Flow
The authentication middleware processes requests in the following order:- Session Authentication - Checks for an active user session (for web dashboard)
- API Key Authentication - Validates the
azen-api-keyheader
API Key Validation
When using API key authentication:- The middleware extracts the API key from the
azen-api-keyheader - The key is verified against the authentication service
- If valid, the request context is populated with:
userId- The user who created the API keyapiKeyId- The unique identifier of the API keyorganizationId- The organization the API key belongs to
Making Authenticated Requests
Example: Create a Memory
Authentication Errors
401 Unauthorized
Returned when theazen-api-key header is missing:
403 Forbidden
Returned when the API key is invalid or disabled:- The API key doesn’t exist
- The API key is disabled
- The API key has expired
- The API key is missing required metadata (organizationId, userId)
429 Rate Limited
Returned when the API key has exceeded its rate limit:API Key Management
API keys are managed through the Azen dashboard at https://azen.sh. Each API key belongs to an organization and can be:- Named - Assign descriptive names to identify keys
- Enabled/Disabled - Toggle key activation status
- Rate Limited - Configure custom rate limits per key
- Expired - Set expiration dates for temporary access
- Tracked - Monitor usage statistics and request counts
API keys are organization-scoped. All memories and operations performed with an API key belong to the key’s organization.
Security Best Practices
- Store keys securely - Use environment variables or secret management services
- Rotate keys regularly - Create new keys and revoke old ones periodically
- Use different keys - Separate keys for development, staging, and production
- Monitor usage - Review API key activity in the dashboard regularly
- Set expiration dates - Use time-limited keys for temporary integrations
- Enable rate limiting - Protect against accidental abuse or compromised keys
Next Steps
Rate Limits
Learn about API rate limiting and token bucket algorithm

