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 and display label. A description is optional but strongly recommended: it is the main signal that distinguishes a class 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

Add subclasses for finer segment labels:
For spreadsheets, the selected subclass is returned on segment.split_class (class in the JSON): its id is "invoice/utility", with parent_id: "invoice" and subcategory_id: "utility". PDFs and other documents ignore subclasses and return the parent class only.
instance_key is deprecated. Existing requests can still return segment.instance when Split finds the requested value. The job’s result includes a deprecation warning. A segment also includes a warning when a required value is missing. Omit the key in new requests.

Control unmatched content

unknown_policy determines what happens to content the classifier does not assign to any class: For PDFs and other documents, every page the model reads gets the closest class, so a single unrelated class still matches. Workbook tabs and JSON sections can come back unclassified when nothing fits. A confirmed blank range in a page document comes back unclassified with a blank_page warning under "include" and "error", and never fails "error". An unconfirmed blank the fast DREX lane serves under "include" stays a plain unclassified range. See Blank pages.
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 workbook tabs and JSON sections that fit no class are 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