Error Handling

pdfRelay uses standard HTTP status codes and returns structured JSON error responses to help you diagnose and handle issues programmatically.

Error Response Format

All error responses follow a consistent JSON structure:

{
  "success": false,
  "error": {
    "code": "INVALID_HTML",
    "message": "The provided HTML could not be parsed.",
    "details": {
      "line": 42,
      "column": 15,
      "snippet": "<div class='unclosed"
    }
  }
}
FieldTypeDescription
successbooleanAlways false for errors
error.codestringMachine-readable error code (see table below)
error.messagestringHuman-readable explanation of the error
error.detailsobject | nullAdditional context (varies by error type)

Error Codes Reference

HTTP StatusCodeDescription
400INVALID_REQUESTThe request body is malformed or missing required fields
400INVALID_HTMLThe HTML content could not be parsed or rendered
400INVALID_OPTIONSOne or more conversion options are invalid
401UNAUTHORIZEDMissing or invalid API key
403FORBIDDENThe API key does not have permission for this action
404NOT_FOUNDThe requested resource (job, document, etc.) does not exist
409SLUG_CONFLICTThe hosting slug is already in use
413PAYLOAD_TOO_LARGEThe request body exceeds the maximum allowed size
429RATE_LIMITEDToo many requests. Check rate limit headers.
429QUOTA_EXCEEDEDMonthly conversion quota exhausted. Upgrade your plan.
500CONVERSION_ERRORAn unexpected error occurred during conversion
503SERVICE_UNAVAILABLEThe service is temporarily unavailable. Retry with backoff.

Structured Error Details

Some error codes include a details object with additional context:

Validation Errors

{
  "success": false,
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Validation failed.",
    "details": {
      "fields": [
        { "field": "html", "message": "html is required" },
        { "field": "options.page_size", "message": "Invalid page size 'B5'. Must be one of: Letter, A4, A3, Legal, Tabloid" }
      ]
    }
  }
}

Rate Limit Errors

{
  "success": false,
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded. Try again in 12 seconds.",
    "details": {
      "limit": 60,
      "remaining": 0,
      "reset_at": "2025-01-15T10:31:00Z",
      "retry_after": 12
    }
  }
}

Best Practices for Error Handling

  • Always check the success field before processing the response.
  • Use the error.code for programmatic handling rather than parsing the message string.
  • Retry on 429 and 503 errors with exponential backoff. Respect the Retry-After header.
  • Do not retry on 400 or 401 errors. These indicate a problem with your request that needs to be fixed.
  • Log the full error response including details to aid in debugging.
Error Handling - pdfRelay Docs | pdfRelay