Using the API

Errors

Errors come in two kinds, and your code should handle both:

  • Request errors are refused straight away, with an HTTP error status. The job was not created.
  • Job errors appear later, on a job that was accepted with 202. The job's state is failed and its error field explains why.

Request error format

{
  "error": {
    "code": "invalid_option",
    "message": "dpi must be between 10 and 600",
    "field": "dpi",
    "request_id": "req_1fefcb5fd322b06f726b38b0"
  }
}
FieldMeaning
codeStable and safe to program against
messageFor people. It may change, so don't test against it.
fieldThe field at fault, when there is one
request_idQuote this when contacting support

Request errors

HTTPCodeWhat to do
400invalid_requestFix the malformed request.
400invalid_optionAn option is unknown or out of range. See field and Conversion options.
400idempotency_key_requiredSend an Idempotency-Key header.
400empty_fileThe uploaded file is empty.
401unauthenticatedThe API key or session is missing, invalid, expired or revoked.
401invalid_credentialsWrong email or password at sign-in.
401reauthentication_requiredEnter your current password to create an API key.
403insufficient_scopeThe key lacks the required scope. Create one with that scope.
403plan_limit_exceededAbove your plan, such as a DPI over its maximum. Lower it or upgrade.
403email_not_verifiedVerify your email first.
403csrf_failedSend X-CSRF-Token with signed-in changes.
403forbiddenOnly workspace owners and admins can do this.
404not_foundNo such resource in your workspace.
409idempotency_key_reusedThe key was used for a different request. See Retries.
409idempotency_in_progressThe first request is still running. Wait for Retry-After.
409job_not_finishedResults were requested too early. Wait for the job.
409too_many_api_keysRevoke a key before creating another.
410result_expiredThe results have been deleted. Convert the PDF again.
413file_too_largeAbove your plan's upload limit.
415not_a_pdfThe file is not a PDF.
415unsupported_media_typeSend multipart/form-data.
429rate_limitedToo many requests. Wait for Retry-After.
429too_many_active_jobsYour plan's limit of jobs at the same time. Wait for one to finish.
500internal_errorOur problem. Retry with backoff.
503not_ready, service_unavailableTemporarily unavailable. Retry with backoff.

Job errors

These appear in the job's error field as {"code": "…", "message": "…"}, and in conversion.failed webhooks. Credits are never charged for pages that didn't convert.

CodeWhat to do
insufficient_creditsNot enough credits for the pages selected. Nothing was charged.
invalid_page_selectionA selected page doesn't exist in this document.
password_requiredThe PDF is protected. Send the password option.
password_incorrectThe password is wrong.
corrupt_pdfThe PDF can't be read.
limit_exceededToo many pages for your plan, or a page is too large. Select fewer pages, lower the DPI or upgrade.
render_failedThe pages couldn't be converted.
timeoutThe job took too long. Try fewer pages or a lower DPI.
partialThe job succeeded, but some pages failed. Check pages_failed and each page's error.
cancelledYou cancelled the job.
internal_error, worker_retries_exhausted, input_missingOur problem. Submit the job again, and contact support if it continues.