Error Handling

Error Response Format

All errors follow this format:

{
  "error": "ERROR_CODE",
  "message": "Human-readable error message"
}

HTTP Status Codes

401 Unauthorized

Invalid or missing API token

{
  "error": "UNAUTHORIZED",
  "message": "Invalid or inactive API token"
}

402 Payment Required

No remaining credits or quota exceeded

{
  "error": "QUOTA_EXCEEDED",
  "message": "No remaining credits for this token."
}

400 Bad Request

Invalid request format or missing required fields

{
  "error": "VALIDATION_ERROR",
  "message": "html field is required"
}

413 Payload Too Large

HTML content exceeds 2MB limit

{
  "error": "PAYLOAD_TOO_LARGE",
  "message": "HTML content exceeds maximum size of 2MB"
}

500 Internal Server Error

Server error during content extraction

{
  "error": "EXTRACTION_ERROR",
  "message": "Content extraction failed"
}

Error Handling Tips

  • Always check the HTTP status code before processing responses
  • Handle 402 errors by purchasing credits or waiting for quota reset
  • Retry 500 errors with exponential backoff
  • Validate HTML size before sending (max 2MB)
  • Check error messages for specific guidance