Error Response Format
All error responses follow this structure:Fields
status- Machine-readable error status (see table below)message- Human-readable error message with contextcode- HTTP status code as an integer
HTTP Status Codes
The API uses the following HTTP status codes mapped to error statuses:| HTTP Code | Status | Description |
|---|---|---|
| 400 | invalid_request | Bad request - validation error or malformed JSON |
| 401 | unauthorized | Not authenticated - missing or empty API key |
| 403 | forbidden | Invalid or disabled API key |
| 404 | not_found | Resource not found |
| 429 | rate_limited | Rate limit exceeded for API key |
| 500 | internal_server_error | Internal server error |
apps/api/src/lib/errorcodes.ts.
Error Codes Reference
400 - Invalid Request
Returned when the request is malformed or fails validation. Invalid JSON:- Missing required fields in request body
- Invalid JSON syntax
- Invalid UUID format in path parameters
- Validation constraints not met (e.g., minLength, maximum values)
401 - Unauthorized
Returned when authentication credentials are missing.- Missing
azen-api-keyheader - Empty API key value
- No active session for web dashboard access
403 - Forbidden
Returned when the API key is invalid, disabled, or lacks required permissions.- API key doesn’t exist in the database
- API key is disabled (
enabled: false) - API key has expired (
expiresAthas passed) - API key is missing required metadata (organizationId, userId)
- User session exists but has no active organization
404 - Not Found
Returned when the requested resource doesn’t exist or doesn’t belong to your organization.- Memory ID doesn’t exist
- Memory belongs to a different organization
- Resource was already deleted
- Invalid endpoint path
429 - Rate Limited
Returned when your API key has exceeded its rate limit.- Too many requests in the time window (default: 60 requests per minute)
- Token bucket is empty (no remaining tokens)
- Burst limit exceeded
500 - Internal Server Error
Returned when an unexpected error occurs on the server. Generic Error:- Database connection issues
- Vector database unavailable
- Encryption/decryption failures
- Unhandled exceptions in business logic
Error Handling
Error Handling Flow
The API handles errors through a global error handler inapps/api/src/index.ts:
Client-Side Error Handling
JavaScript/TypeScript:Best Practices
- Always check HTTP status codes before parsing response body
- Handle rate limits gracefully with exponential backoff
- Log error messages for debugging and monitoring
- Don’t expose internal errors to end users
- Implement retry logic for transient errors (500, 429)
- Validate input on the client side to avoid 400 errors
- Securely store API keys to prevent 401/403 errors
Next Steps
Authentication
Learn about API authentication
Rate Limits
Understand rate limiting policies
Memory API
Start making API requests
API Overview
Review API basics and patterns

