Parse File
Parse files to get cleaned, chunked target content (e.g. markdown).
The Parse endpoint allows you to convert documents into structured, machine-readable formats with fine-grained control over the parsing process. This endpoint is ideal for extracting cleaned document content to be used as context for downstream processing, e.g. RAG pipelines, structured data extraction, embeddings classification, etc.
Unlike processor and workflow runs, parsing is a synchronous endpoint and returns the parsed content in the response. Expected latency depends primarily on file size. This makes it suitable for workflows where you need immediate access to document content without waiting for asynchronous processing.
For a deeper guide on how to use the output of this endpoint, jump to Using Parsed Output.
This endpoint is currently in beta
, but the core interface of the API can be treated as a stable release.
Body
A file object containing either a URL or base64 encoded content. Must contain either fileUrl, fileBase64 or fileId.
Configuration options for the parsing process.
Response
The type of object. Will always be “parser_run”.
A unique identifier for the parser run.
The identifier of the file that was parsed. This can be used as a parameter to other Extend endpoints, such as processor runs. This allows downstream processing to reuse a cache of the parsed file content to reduce your usage costs.
An array of chunks extracted from the document.
The status of the parser run. Possible values:
PROCESSED
: The file was successfully processedFAILED
: The processing failed (see failureReason for details)
The reason for failure if status is “FAILED”. Will be null for successful runs.
The configuration used for the parsing process, including any default values that were applied.
Metrics about the parsing process.
Using Parsed Output
The Parse API returns document content in a structured format that provides both high-level formatted content and detailed block-level information. Understanding how to work with this output will help you get the most value from the parsing service.
Working with Chunks
Each chunk (currently only page-level chunks are supported) contains two key properties:
-
content
: A fully formatted representation of the entire chunk in the target format (e.g., markdown). This is ready to use as-is if you need the complete formatted content of a page. -
blocks
: An array of individual content blocks that make up the chunk, each with its own formatting, position information, and metadata.
When to use chunk.content
vs. chunk.blocks
-
Use
chunk.content
when:- You need the complete, properly formatted content of a page, already doing the logical placement of blocks (e.g. grouping markdown sections and placing spatially, etc)
- You want to display or process the document content as a whole (and can just combine all chunk.content values)
- You’re integrating with systems that expect formatted text (e.g., markdown processors)
-
Use
chunk.blocks
when:- You need to work with specific elements of the document (e.g., only tables or figures)
- You need spatial information about where content appears on the page, perhaps to build citation systems
- You’re building a UI that shows or highlights specific document elements
Example: Extracting specific content types
Example: Reconstructing content with custom formatting
Spatial Information
Each block contains spatial information in the form of a polygon
(precise outline) and a simplified boundingBox
. This information can be used to:
- Highlight specific content in a document viewer
- Create visual overlays on top of the original document
- Understand the reading order and layout of the document
By leveraging both the formatted content and the structured block information, you can build powerful document processing workflows that combine the convenience of formatted text with the precision of block-level access.
Error Response Format
When an error occurs, the API returns a structured error response with the following fields:
A specific error code that identifies the type of error.
A human-readable description of the error.
A unique identifier for the request, useful for troubleshooting.
Indicates whether retrying the request might succeed.
Custom Error Codes
The API may return the following specific error codes:
Custom Error Codes
We provide custom error codes to make it easier for your system to know what happened in case of a failure. There will also be a retryable=true|false
field in the response body, but you can also find a breakdown below. Most errors are not retryable and are client errors related to the file provided for parsing.
Error Code | Description | Retryable |
---|---|---|
UNABLE_TO_DOWNLOAD_FILE | The system could not download the file from the provided URL, likely means your presigned url is expired, or malformed somehow. | ❌ |
FILE_TYPE_NOT_SUPPORTED | The file type is not supported for parsing. | ❌ |
FILE_SIZE_TOO_LARGE | The file exceeds the maximum allowed size. | ❌ |
CORRUPT_FILE | The file is corrupt and cannot be parsed. | ❌ |
OCR_ERROR | An error occurred in the OCR system. This is a rare error code and would indicate downtime, so requests can be retried. We’d suggest applying a retry with backoff for this error. | ✅ |
PASSWORD_PROTECTED_FILE | The file is password protected and cannot be parsed. | ❌ |
FAILED_TO_CONVERT_TO_PDF | The system could not convert the file to PDF format. | ❌ |
FAILED_TO_GENERATE_TARGET_FORMAT | The system could not generate the requested target format. | ❌ |
INTERNAL_ERROR | An unexpected internal error occurred. We’d suggest applying a retry with backoff for this error as it likely a result of some outage. | ✅ |
HTTP error codes
Corresponding http error codes for different types of failures. We generally recommend relying on our custom error codes for programmatic handling.
Returned when:
- Required fields are missing (e.g.,
file
) - Neither
fileUrl
norfileBase64
is provided in the file object - The provided
fileUrl
is invalid - The provided
fileBase64
is invalid - The
config
contains invalid values (e.g., unsupported target format or chunking strategy) - The file type is not supported
- The file size is too large
Returned when:
- The API token is missing
- The API token is invalid
Returned when:
- The authenticated workspace doesn’t have permission to use the parse functionality
- The API token doesn’t have sufficient permissions
Returned when:
- The file is corrupt and cannot be parsed
- The file is password protected
- The file could not be converted to PDF
- The system failed to generate the target format
Returned when:
- An OCR error occurs
- A chunking error occurs
- Any other unexpected error occurs during parsing
Handling Errors
Here are examples of how to handle errors from the Parse API: