Standard Error Response Format
All error responses follow this consistent structure:HTTP Status Codes
400 Bad Request
When it occurs: Invalid input parameters, malformed requests, or validation failures. Example Response:- Missing required parameters
- Invalid parameter formats
- Malformed JSON in request body
- Invalid file formats
- Attempting to delete default sub-tenant
401 Unauthorized
When it occurs: Invalid or missing API key, authentication required. Example Response:- Missing API key in headers
- Invalid API key
- Expired API key
- Insufficient permissions
403 Forbidden
When it occurs: Valid authentication but insufficient permissions for the requested resource. Example Response:- API key lacks required permissions
- Tenant access restrictions
- Resource ownership conflicts
404 Not Found
When it occurs: Requested resource does not exist. Example Response:- Tenant does not exist
- Sub-tenant does not exist
- File/document not found
- User memory not found
- Source not found
409 Conflict
When it occurs: Resource already exists or conflicts with existing data. Example Response:- Tenant ID already exists
- Duplicate file uploads
- Conflicting metadata schemas
422 Unprocessable Entity
When it occurs: Request is well-formed but contains semantic errors. Example Response:- Invalid metadata schema
- Content validation failures
- Business rule violations
- Data format incompatibilities
500 Internal Server Error
When it occurs: Unexpected server-side error. Example Response:Error Handling: Always check the
detail
object in error responses for the actual error information. The outer structure may vary, but the detail
object always follows the standard format.- Database connectivity issues
- Processing pipeline failures
- External service unavailability
- System resource constraints
Endpoint-Specific Error Codes
Tenant Management
TENANT_ALREADY_EXISTS
: Tenant ID is already in useTENANT_NOT_FOUND
: Specified tenant does not existINVALID_TENANT_ID
: Tenant ID format is invalid
Sub-Tenant Management
CANNOT_DELETE_DEFAULT_SUB_TENANT
: Attempting to delete the default sub-tenantSUB_TENANT_NOT_FOUND
: Specified sub-tenant does not existINVALID_SUB_TENANT_ID
: Sub-tenant ID format is invalid
Document Management
FILE_NOT_FOUND
: Requested file does not existINVALID_FILE_FORMAT
: Unsupported file formatFILE_TOO_LARGE
: File exceeds size limitsPROCESSING_FAILED
: Document processing encountered an error
Search Operations
INVALID_SEARCH_PARAMETERS
: Search query parameters are invalidSEARCH_TIMEOUT
: Search operation timed outNO_RESULTS_FOUND
: No matching results for the search query
User Memory
MEMORY_NOT_FOUND
: User memory does not existMEMORY_LIMIT_EXCEEDED
: User has reached memory storage limitINVALID_MEMORY_FORMAT
: Memory content format is invalid
Embeddings
EMBEDDINGS_NOT_FOUND
: Requested embeddings do not existINVALID_EMBEDDING_FORMAT
: Embedding data format is invalidEMBEDDING_GENERATION_FAILED
: Failed to generate embeddings
Error Handling Best Practices
Client-Side Error Handling
Retry Logic
For transient errors (5xx), implement exponential backoff:Troubleshooting Common Issues
Authentication Issues
- Check API Key: Ensure your API key is valid and not expired
- Header Format: Verify the Authorization header format:
Bearer YOUR_API_KEY
- Permissions: Confirm your API key has the required permissions
Resource Not Found
- Verify IDs: Double-check tenant_id, sub_tenant_id, and file_id values
- Case Sensitivity: Ensure IDs match exactly (case-sensitive)
- Existence: Confirm the resource exists before making requests
Validation Errors
- Required Fields: Ensure all required parameters are provided
- Data Types: Verify parameter types match the expected format
- File Formats: Check that uploaded files are in supported formats
Rate Limiting
- Request Frequency: Reduce the frequency of API calls
- Batch Operations: Use batch endpoints when available
- Caching: Implement client-side caching for frequently accessed data
Error Code Consistency: All error codes follow a consistent naming convention using UPPER_SNAKE_CASE. This makes it easy to programmatically handle specific error scenarios in your application.
Error Response Structure: Always check the
detail
object in error responses, as this contains the actual error information. The outer structure may vary, but the detail
object always follows the standard format.