For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Book a demoLog in
DocumentationAPI ReferenceModel VersioningChangelog
DocumentationAPI ReferenceModel VersioningChangelog
    • Studio
    • Support
    • Benchmarks
    • Status
  • Getting Started
    • Overview
    • API Quickstart
    • Dashboard Quickstart
    • Agent Quickstart
  • Dev Tools
    • SDKs
    • CLI
  • Capabilities
      • Overview
      • Configuration
      • Response Format
      • Best Practices
      • Error Handling
      • Generate Edit Schema
LogoLogo
Book a demoLog in
On this page
  • How failures surface: sync vs. async
  • Failure reasons
  • HTTP status codes
  • 400 Bad Request
  • 401 Unauthorized
  • 402 Payment Required
  • 403 Forbidden
  • 404 Not Found
  • 422 Unprocessable Entity
  • 429 Too Many Requests
  • 500 Internal Server Error
  • Handling errors
CapabilitiesEditing

Error Handling

Was this page helpful?
Previous

Generate Edit Schema

Next
Built with

When an error occurs, the Edit API returns a structured error with the following fields:

FieldTypeDescription
codestringA specific error code for programmatic handling.
messagestringA human-readable description of the error. Don’t rely on its exact text — it may change.
retryablebooleanWhether retrying the request might succeed. When true, retry with exponential backoff.
requestIdstringA unique identifier for the request, useful when contacting support.

How failures surface: sync vs. async

Where an error shows up depends on which endpoint you use.

  • Synchronous (/edit) waits for processing to finish, so every failure — both request validation and document processing — comes back as an HTTP error response with the fields above. The HTTP status codes below apply to this endpoint.
  • Asynchronous (/edit_runs) returns 200 with an edit run as soon as the job is accepted. Request-level problems (invalid request, auth) still return an HTTP error at creation time, but document processing failures are not HTTP errors — the run instead reaches status: "FAILED" with a failureReason and failureMessage (one of the failure reasons below), which you read when you poll or receive the webhook.

Production integrations should use the asynchronous /edit_runs endpoint and check status on the returned run. See Move to production with async processing.

Failure reasons

These codes describe why an edit failed. On the sync endpoint they appear in the error body’s code field; on the async endpoint they appear as the run’s failureReason. Most are client errors related to the file or config and are not retryable. The structured error’s retryable flag is authoritative at runtime.

Failure reasonDescriptionRetryable
UNABLE_TO_DOWNLOAD_FILEFailed to load the requested file (e.g. an expired or malformed URL).❌
FILE_TYPE_NOT_SUPPORTEDFile type not supported. Edit runs currently require a PDF.❌
FILE_SIZE_TOO_LARGEThe file exceeds the maximum allowed size.❌
CORRUPT_FILEThe file appears to be corrupted and cannot be edited.❌
FIELD_DETECTION_ERRORAn error occurred during field detection.❌
OCR_ERRORAn error occurred in the OCR system.✅
PASSWORD_PROTECTED_FILEThe file is password protected. Retry with the file’s password using file.settings.password. See Password-Protected Files.❌
FAILED_TO_CONVERT_TO_PDFThe file could not be converted to PDF for processing.❌
INVALID_OPTIONSThe provided configuration options are invalid.❌
SCHEMA_VALIDATION_FAILEDThe provided schema failed validation.❌
EMPTY_SCHEMANo schema was provided and no fields could be detected.❌
OUT_OF_CREDITSInsufficient credits to process the file.❌
INTERNAL_ERRORAn unexpected internal error occurred.✅

Additional failure reasons may be added in the future. Handle unknown values gracefully.

HTTP status codes

These HTTP status codes are returned by the synchronous /edit endpoint. On the asynchronous /edit_runs endpoint, only request-level errors are returned at creation time — processing failures surface on the run as status: "FAILED". We generally recommend relying on the failure reasons above for programmatic handling.

400 Bad Request

Returned when required fields are missing (e.g. file), the file locator is invalid, or the config contains invalid options.

401 Unauthorized

Returned when the API token is missing or invalid.

402 Payment Required

Returned when the workspace has insufficient credits to process the file.

403 Forbidden

Returned when the authenticated workspace or token doesn’t have permission to use the edit functionality.

404 Not Found

Returned when a referenced file or resource cannot be found.

422 Unprocessable Entity

Returned when the file cannot be processed — for example, it is corrupt, password protected, or could not be converted to PDF.

429 Too Many Requests

Returned when you exceed the rate limit. Retry with exponential backoff.

500 Internal Server Error

Returned when an unexpected error occurs during editing. Retry with exponential backoff.

Handling errors

Error handling differs between the two endpoints: with sync you catch a thrown HTTP error, while with async you also check the run’s terminal status. Pick the tab that matches how you call Edit.

Synchronous (/edit)
Asynchronous (/edit_runs)

Catch the HTTP error and inspect its status code and body.

Python
TypeScript
Java
Go
1from extend_ai import Extend
2from extend_ai.core.api_error import ApiError
3
4client = Extend(token="your_api_key")
5
6try:
7 result = client.edit(
8 file={"url": "https://example.com/form.pdf"},
9 config={"instructions": "Fill out the form with the provided data."},
10 )
11except ApiError as e:
12 # e.body holds the structured error: { code, message, retryable, requestId }
13 body = e.body or {}
14 if body.get("retryable"):
15 ... # retry with exponential backoff
16 print(f"edit failed ({e.status_code}): {body.get('code')} — {body.get('message')}")
17 raise

For retryable errors (OCR_ERROR, INTERNAL_ERROR, or any 5xx), retry with exponential backoff. Always log the requestId when contacting support.