> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ndi.nace.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Split

> Cut a packet or workbook into classified segments

```ts theme={"dark"}
import { NdiClient } from "ndi-sdk";

const client = new NdiClient();
const packet = await client.documents.createUpload("packet.pdf");
const job = await client.jobs.wait(
  (
    await client.documents.split(packet, {
      classes: [
        { id: "invoice", label: "Invoice", description: "A supplier invoice" },
        { id: "receipt", label: "Receipt", description: "A payment receipt" },
      ],
      wait_seconds: 30,
    })
  ).job_id,
);
if (job.result?.result_type === "split" && "segments" in job.result) {
  for (const segment of job.result.segments) {
    console.log(segment.start_page, segment.end_page, segment.split_class);
  }
}
```

## Method signature

```text theme={"dark"}
split(
  source: DocumentSource | UploadResponse,
  opts: {
    classes: SplitCategory[];
    unknown_policy?: "include" | "force" | "error";
    page_ranges?: PageRange[];
    overlap_policy?: "exclusive" | "shared_boundary_page";
    quality?: "auto";
    split_rules?: string;
    output?: SplitOutputOptions;
    wait_seconds?: number;
    idempotency_key?: string;
  },
): Promise<Job>
```

### Parameters

| Parameter             | Type                                     | Required | Description                            |
| --------------------- | ---------------------------------------- | -------- | -------------------------------------- |
| `source`              | `DocumentSource` or `UploadResponse`     | Yes      | Packet, workbook, or prior parse       |
| `opts.classes`        | `SplitCategory[]`                        | Yes      | Classes to cut on                      |
| `opts.unknown_policy` | `"include"` / `"force"` / `"error"`      | No       | Default `include`                      |
| `opts.page_ranges`    | `PageRange[]`                            | No       | Not supported for spreadsheets         |
| `opts.overlap_policy` | `"exclusive"` / `"shared_boundary_page"` | No       | Shared boundary is reserved            |
| `opts.quality`        | `"auto"`                                 | No       | Only accepted value                    |
| `opts.split_rules`    | `string`                                 | No       | Extra cutting instructions             |
| `opts.output`         | `SplitOutputOptions`                     | No       | `include_content`, `materialize_files` |
| `opts.wait_seconds`   | `number`                                 | No       | Hold the HTTP response open (max 300)  |

### Returns

A `Job`. On success, `result.segments` is the ordered cut list.

See [Split guide](/guides/split).
