Error Response Format
All errors follow a consistent JSON structure:HTTP Status Codes
Imperial uses standard HTTP status codes to indicate success or failure.Success Codes
| Code | Name | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created successfully (uploads) |
Client Error Codes (4xx)
400 Bad Request
400 Bad Request
The request was malformed or contains invalid parameters.Common Causes:Solutions:
- Missing required fields
- Invalid file format
- Malformed JSON
- Invalid query parameters
- Check request body format
- Verify all required fields are present
- Ensure file is properly attached
- Validate parameter types
401 Unauthorized
401 Unauthorized
403 Forbidden
403 Forbidden
Authenticated but lacking required permissions.Common Causes:Solutions:
- Upload key used for non-upload endpoints (Free/Starter)
- Trying to access another user’s resources
- Tier doesn’t support requested feature
- Upgrade to Pro/Business for full API access
- Use correct authentication type for endpoint
- Verify you own the resource you’re accessing
404 Not Found
404 Not Found
The requested resource doesn’t exist.Common Causes:Solutions:
- Invalid image/upload ID
- File was deleted
- Typo in endpoint URL
- Verify resource ID is correct
- Check if file was deleted
- Ensure you own the resource
- Verify endpoint URL is correct
413 Payload Too Large
413 Payload Too Large
File size or total request size exceeds limits.Common Causes:Solutions:
- Storage limit exceeded
- File larger than available space
- Batch upload too large
- Delete old uploads to free space
- Enable auto-compression
- Upgrade to higher tier
- Split large batch uploads
415 Unsupported Media Type
415 Unsupported Media Type
File type is not supported.Common Causes:Solutions:
- Uploading non-image/video files
- Unsupported video codec
- Corrupted file
- Use supported formats: JPEG, PNG, WebP, GIF, MP4, WebM, MOV, AVI
- Verify file isn’t corrupted
- Check MIME type is correct
429 Too Many Requests
429 Too Many Requests
Rate limit exceeded.Common Causes:Solutions:
- Too many requests per minute
- Operations limit reached for month
- Aggressive retry logic
- Respect
Retry-Afterheader - Implement exponential backoff
- Reduce request frequency
- Upgrade tier for higher rate limits
Server Error Codes (5xx)
500 Internal Server Error
500 Internal Server Error
An unexpected error occurred on the server.Common Causes:Solutions:
- Database connectivity issues
- R2 storage unavailable
- Unhandled exception
- Retry the request after a delay
- Check status page for incidents
- Contact support if persistent
- Implement retry logic with backoff
503 Service Unavailable
503 Service Unavailable
Common Error Scenarios
Authentication Errors
Upload Errors
Permission Errors
Rate Limiting
Rate Limit Headers
Every response includes rate limit information:| Header | Description |
|---|---|
X-RateLimit-Limit | Max requests per window |
X-RateLimit-Remaining | Requests left in window |
X-RateLimit-Reset | Unix timestamp when limit resets |
Handling Rate Limits
Best Practices
Error Handling
1
Check Status Code First
Use HTTP status code to determine error category (4xx vs 5xx)
2
Parse Error Message
Display
error field to users for actionable feedback3
Log Error Details
Store
details object for debugging and support requests4
Implement Retry Logic
Retry 5xx errors with exponential backoff. Don’t retry 4xx errors.

