HTTP Status Codes
OK
Request processed successfully
All endpoints return 200 for successful operations
Bad Request
Invalid request format, missing parameters, or malformed data
Check request body, file format, and required parameters
Unauthorized
Invalid, missing, or malformed API key
Verify Authorization header format: Bearer pk_live_...
Payment Required
Insufficient credit balance for operation
Purchase credits via dashboard or check balance
Forbidden
API key lacks required permissions for endpoint
Check API key permissions in dashboard
Payload Too Large
File exceeds maximum size limit (10MB)
Compress file or split into smaller parts
Unprocessable Entity
Valid request but content cannot be processed
PDF corrupted, no form fields, or unsupported content
Too Many Requests
Rate limit exceeded for API key
Implement exponential backoff and retry logic
Internal Server Error
Unexpected server error during processing
Retry request or contact support with request ID
Error Response Format
{
"error": "Insufficient balance",
"message": "Not enough credits to process this request",
"details": {
"code": "INSUFFICIENT_BALANCE",
"amountRequired": 0.02,
"currentBalance": 0.01,
"pageCount": 1,
"suggestion": "Purchase credits via dashboard"
},
"timestamp": "2024-01-15T10:30:00Z",
"requestId": "req_abc123"
}
{
"error": "Bad Request",
"message": "Invalid file format",
"details": {
"code": "INVALID_FILE_FORMAT",
"allowedFormats": ["pdf"],
"receivedFormat": "docx",
"field": "file"
},
"timestamp": "2024-01-15T10:30:00Z",
"requestId": "req_def456"
}
Detailed Error Codes
Authentication Errors
MISSING_API_KEY
401Authorization header is missing
Include: Authorization: Bearer your_api_key
INVALID_API_KEY
401API key is malformed or invalid
Check key format: pk_live_ or pk_test_
API_KEY_REVOKED
401API key has been deactivated
Generate new key in dashboard
INSUFFICIENT_PERMISSIONS
403API key lacks endpoint permissions
Update key permissions in dashboard
File Processing Errors
INVALID_FILE_FORMAT
400File is not a valid PDF
Only PDF files are supported
FILE_TOO_LARGE
413File exceeds 10MB limit
Compress file or contact support for large files
CORRUPTED_PDF
422PDF file is corrupted or unreadable
Try re-saving or repairing the PDF
NO_FORM_FIELDS
422PDF contains no fillable form fields
Ensure PDF has interactive form fields
NO_TEXT_CONTENT
422PDF contains no extractable text
Document may be image-only or blank
Payment & Credit Errors
INSUFFICIENT_BALANCE
402Not enough credits for operation
Purchase credits via dashboard
ACCOUNT_SUSPENDED
402Account suspended due to payment issues
Contact support to resolve
Rate Limiting Errors
RATE_LIMIT_EXCEEDED
429Too many requests in time window
Implement exponential backoff
CONCURRENT_LIMIT_EXCEEDED
429Too many concurrent requests
Queue requests or reduce concurrency
Server Errors
PROCESSING_ERROR
500Unexpected processing error
Retry request or contact support
SERVICE_UNAVAILABLE
503Service temporarily unavailable
Check status page and retry later
Error Handling Best Practices
Retry Logic
async function processWithRetry(url, formData, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const response = await fetch(url, {
method: 'POST',
headers: { 'Authorization': 'Bearer pk_live_...' },
body: formData
});
if (response.ok) {
return await response.blob();
}
const error = await response.json();
// Don't retry client errors (4xx)
if (response.status >= 400 && response.status < 500) {
throw new Error(`Client error: ${error.message}`);
}
// Retry server errors (5xx) and rate limits (429)
if (attempt === maxRetries) {
throw new Error(`Max retries exceeded: ${error.message}`);
}
// Exponential backoff
const delay = Math.pow(2, attempt) * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
} catch (err) {
if (attempt === maxRetries) throw err;
}
}
}
Error Response Handling
async function handleApiResponse(response) {
if (response.ok) {
return await response.blob();
}
const error = await response.json();
switch (response.status) {
case 400:
throw new ValidationError(error.message, error.details);
case 401:
throw new AuthenticationError('Invalid API key');
case 402:
throw new PaymentError('Insufficient balance', error.details);
case 403:
throw new PermissionError('Access forbidden');
case 413:
throw new FileSizeError('File too large');
case 422:
throw new ProcessingError('Cannot process file', error.details);
case 429:
throw new RateLimitError('Rate limit exceeded', error.details);
case 500:
throw new ServerError('Server error', error.requestId);
default:
throw new ApiError(`HTTP ${response.status}: ${error.message}`);
}
}
// Custom error classes for better error handling
class ValidationError extends Error {
constructor(message, details) {
super(message);
this.name = 'ValidationError';
this.details = details;
}
}
Error Prevention Tips
• Validate file format and size before upload
• Check API key format (pk_live_ or pk_test_)
• Verify required parameters are present
• Test with sample files first
• Implement client-side validation
• Monitor credit balance regularly
• Set up low balance alerts
• Track error rates and patterns
• Log request IDs for debugging
• Implement health checks