Skip to main content
documents.split finds logical documents inside one file. PDFs and other page-based sources become ordered page-range segments. Workbooks become one segment per worksheet, classified against the classes you provide.

Basic usage


Method signature

Parameters

Returns

A Promise<Job>. After success, result.result_type === "split" and result.segments is the ordered cut list.

Define classes

Each class needs a stable id, display label, and a description that distinguishes it from nearby classes:
Avoid labels whose descriptions overlap completely. The id is what appears in result joins; keep it stable if you revise display text.

Subclasses and instance keys

Add subclasses for finer segment labels and an instance key when each segment should carry a document identifier:
The selected subclass is returned with the segment classification. segment.instance carries the requested key and extracted value when one is available.

Control unmatched content

unknown_policy determines what happens when content matches none of the classes:
Use "include" when completeness matters. Use "force" only when every page must belong to one of a closed set of classes.

Page selection and parse mode

Page ranges are not supported for spreadsheet sources. Use "medium" or "high" only when the default parse is not sufficient; higher modes add latency.

Split rules

Use split_rules for a boundary convention the class descriptions do not express:
Use overlap_policy: "shared_boundary_page" when the page at a detected boundary belongs to both neighboring documents. The default "exclusive" policy keeps every source page in only one segment.

Include content or files

Document segments are materialized only when requested. Spreadsheet segments always include a single-sheet .xlsx artifact.

Response structure

Page-based segments use start_page and end_page. Spreadsheet segments use sheet_name; their page values correspond to the worksheet’s one-based position. JSON sources may use json_pointer. classification_confidence and boundary_confidence contain a readable band and an optional score. "unavailable" means no score was produced, not zero confidence.

Reuse a parse


Complete example


Error handling

Common failures include empty or invalid classes, unsupported file types, spreadsheet page ranges, and unknown_policy: "error" when content is unclassified.

Best practices

Define distinct classes

Give each class a stable ID and a description that separates it from adjacent classes.

Keep unknowns visible

Start with unknown_policy: "include" so unexpected packet content is not silently forced.

Add rules for boundaries

Use split_rules for continuation pages or identifier changes, not to replace class descriptions.

Materialize only when needed

Request files when downstream systems need individual documents; use inline content for inspection.

Next steps