Skip to main content

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

Client Error Codes (4xx)

The request was malformed or contains invalid parameters.Common Causes:
  • Missing required fields
  • Invalid file format
  • Malformed JSON
  • Invalid query parameters
Example:
Solutions:
  • Check request body format
  • Verify all required fields are present
  • Ensure file is properly attached
  • Validate parameter types
Missing or invalid authentication credentials.Common Causes:
  • Missing Authorization header
  • Invalid API key or upload key
  • Expired token
  • Wrong key format
Example:
Solutions:
  • Include Authorization: Bearer YOUR_KEY header
  • Verify key starts with imperial_live_ or imperial_upload_
  • Generate new key if compromised
  • Check key hasn’t been revoked
Authenticated but lacking required permissions.Common Causes:
  • Upload key used for non-upload endpoints (Free/Starter)
  • Trying to access another user’s resources
  • Tier doesn’t support requested feature
Example:
Solutions:
  • Upgrade to Pro/Business for full API access
  • Use correct authentication type for endpoint
  • Verify you own the resource you’re accessing
The requested resource doesn’t exist.Common Causes:
  • Invalid image/upload ID
  • File was deleted
  • Typo in endpoint URL
Example:
Solutions:
  • Verify resource ID is correct
  • Check if file was deleted
  • Ensure you own the resource
  • Verify endpoint URL is correct
File size or total request size exceeds limits.Common Causes:
  • Storage limit exceeded
  • File larger than available space
  • Batch upload too large
Example:
Solutions:
  • Delete old uploads to free space
  • Enable auto-compression
  • Upgrade to higher tier
  • Split large batch uploads
File type is not supported.Common Causes:
  • Uploading non-image/video files
  • Unsupported video codec
  • Corrupted file
Example:
Solutions:
  • Use supported formats: JPEG, PNG, WebP, GIF, MP4, WebM, MOV, AVI
  • Verify file isn’t corrupted
  • Check MIME type is correct
Rate limit exceeded.Common Causes:
  • Too many requests per minute
  • Operations limit reached for month
  • Aggressive retry logic
Example:
Solutions:
  • Respect Retry-After header
  • Implement exponential backoff
  • Reduce request frequency
  • Upgrade tier for higher rate limits

Server Error Codes (5xx)

An unexpected error occurred on the server.Common Causes:
  • Database connectivity issues
  • R2 storage unavailable
  • Unhandled exception
Example:
Solutions:
  • Retry the request after a delay
  • Check status page for incidents
  • Contact support if persistent
  • Implement retry logic with backoff
Service is temporarily unavailable.Common Causes:
  • Planned maintenance
  • Database migration
  • CDN issues
Example:
Solutions:
  • Wait and retry after specified time
  • Check status page for updates
  • Implement circuit breaker pattern

Common Error Scenarios

Authentication Errors

Upload Errors

Permission Errors

Rate Limiting

Rate Limit Headers

Every response includes rate limit information:

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 feedback
3

Log Error Details

Store details object for debugging and support requests
4

Implement Retry Logic

Retry 5xx errors with exponential backoff. Don’t retry 4xx errors.

Retry Strategy

When to Retry: - ✅ 500 Internal Server Error - ✅ 503 Service Unavailable - ✅ 429 Rate Limited (with backoff) - ❌ 400-404 Client Errors (fix request instead)

Logging

Log these fields for troubleshooting:

Testing Errors

Development Tips

Get Help

Join Discord

Ask the community for help

Check Status

View API status and incidents

View Limits

Understand operations and storage

Upgrade Tier

Resolve limit-related errors