---
title: "Cut a PDF into child files by page range"
---

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

# Cut a PDF into child files by page range

Path: CloudRaker Paperwork API › Spaces

`POST /v1/spaces/{spaceId}/split`

[Classify](https://docs.cloudraker.com/paperwork/capabilities/classify) decides. Split cuts — it runs no model, has no classes and no configuration.

**PDF only.** Office, image, audio and video inputs fail the run with `unsupported_split_source`.

Send exactly one of:

- `segments` — your own ranges, 1-based inclusive, ascending, non-overlapping, at most 100. Gaps are allowed. This path costs no model call at all.
- `classifyRunId` — a page-mode classify run on the same file. Its `segments[]` are used as-is, with `classId` and `confidence` echoed onto each child.

Each child is a real file with its own `fileId`, ready for [POST /v1/extract](https://docs.cloudraker.com/paperwork/api/capabilities/extract); `output.documentIds` is the same list flattened. Children inherit the parent's `metadata`, gain `metadata.parentRunId`, land in the parent's space and share the run's TTL — call [keep](https://docs.cloudraker.com/paperwork/api/runs/keep-run) to move parent and children together.

Send `materialize: false` to get the ranges back without creating anything: the safe first call on a large packet.

```json
{
  "file": { "id": "file_01K3F…" },
  "classifyRunId": "clr_01K3F…"
}
```

> **Note:** Children are parsed right after the split, so they are immediately usable by any verb. Each child's parse is billed as a normal parse. `usage` itemizes it.

### Waiting for the result

Sync by default: the call holds open until the run finishes, up to `?wait=` seconds (default `60`, max `120`, `0` returns immediately).

| Outcome | Response |
| --- | --- |
| Finished inside the window | `200` with the full run |
| Still running at the cap | `202` with `{object, id, status, statusUrl}` |

> **Note:** The `202` is a graceful degrade, never an error — poll [the run](https://docs.cloudraker.com/paperwork/api/runs/get-run) or wait for a [webhook](https://docs.cloudraker.com/paperwork/api/webhook-endpoints/create-webhook-endpoint). Replaying an `idempotency-key` returns the original run alongside an `idempotent-replay: true` response header.

**Learn more:** [Split guide](https://docs.cloudraker.com/paperwork/capabilities/split)

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `spaceId` (`spaceSplit.path.spaceId`; string, required)

## Query parameters

- `wait` (`spaceSplit.query.wait`; integer, optional) — How many seconds to hold the request open waiting for the run to finish. Finishing inside the window returns `200` with the full run; running past it returns `202` with a `statusUrl` to poll. Send `0` to skip waiting entirely and always get the `202`.
  - min 0; max 120; default `60`

## Request body

_Required._

- `file` (`spaceSplit.file`; any of, required) — An input file, given one of two ways. - `{ "url": "…", "name"?: "…", "processing"?: "…" }` — fetched over http(s) for this run and purged with it. - `{ "id": "…" }` — a file you already registered with `POST /v1/files`, reusable across runs and never re-parsed. - `{ "id": "…", "ephemeral": true }` — a file you uploaded only for this run, purged with it. Use it only on a file no other run uses.
  - any of:
    - `object`
      - `url` (`spaceSplit.file.1.url`; string, required)
        - format `uri`
      - `name` (`spaceSplit.file.1.name`; string, optional)
        - minLength 1
      - `processing` (`spaceSplit.file.1.processing`; string, optional)
        - one of `"auto"`, `"ocr"`, `"simple"`, `"transcribe"`, `"transcribe_diarize"`
    - `object`
      - `id` (`spaceSplit.file.2.id`; string, required)
        - minLength 1
      - `ephemeral` (`spaceSplit.file.2.ephemeral`; boolean, optional) — Purge this file with the run (TTL expiry or `DELETE /v1/runs/{id}`), unless you `keep` the run. API workspace only: ignored under `/v1/spaces/{spaceId}/…`.
- `segments` (`spaceSplit.segments`; array<object>, optional) — The ranges to cut, 1-based inclusive, ascending and non-overlapping, at most 100. Gaps are allowed — drop a separator page on purpose. Send this or `classifyRunId`, never both.
  - `startPage` (`spaceSplit.segments.startPage`; integer, required)
    - min 1; max 9007199254740991
  - `endPage` (`spaceSplit.segments.endPage`; integer, required)
    - min 1; max 9007199254740991
  - `classId` (`spaceSplit.segments.classId`; string, optional)
    - pattern `^[a-z0-9][a-z0-9_-]{0,63}$`
- `classifyRunId` (`spaceSplit.classifyRunId`; string, optional) — A page-mode classify run to take the ranges from. Its `output.segments` are copied verbatim, `classId` and confidence included. The run must be on the same file and must not have expired.
  - minLength 1; example `"clr_01K3F0000000000000000000"`
- `materialize` (`spaceSplit.materialize`; boolean, optional) — Whether to create the child files. `false` returns the ranges only and creates nothing — the safe first call on a large packet.
  - default `true`
- `metadata` (`spaceSplit.metadata`; map<unknown>, optional) — Arbitrary JSON you attach to the run and get back on every read of it. Use it to carry your own identifiers — an order number, a customer id — so a webhook or a polled run reconciles without a lookup table. Capped at 10 KB serialized.
- `webhook` (`spaceSplit.webhook`; any of, optional) — Where to deliver this run's events, given one of two ways. - `{ "url": "…" }` — a one-off https endpoint for this run only. - `{ "id": "whe_…" }` — a saved endpoint from `POST /v1/webhooks`. Runs hold the reference, so pausing or re-pointing that endpoint applies to this run too. Deliveries are at-least-once and signed — dedupe on `eventId` and verify against `GET /v1/webhooks/jwks.json`.
  - any of:
    - `object`
      - `url` (`spaceSplit.webhook.1.url`; string, required)
        - format `uri`
    - `object`
      - `id` (`spaceSplit.webhook.2.id`; string, required)
        - minLength 1
- `ttl` (`spaceSplit.ttl`; integer, optional) — How long, in seconds, to keep this run and its files before purging them automatically. The maximum is 604800 (7 days). The deadline comes back as `expiresAt` on every read of the run. Call `POST /v1/runs/{id}/keep` before then to clear the TTL and move the results into a space permanently. E-signature runs are exempt — an envelope waits for its signers however long that takes.
  - min 1; max 604800; default `86400`

## Example request

```json
{
  "file": {
    "url": "http://example.com",
    "name": "string",
    "processing": "auto"
  },
  "segments": [
    {
      "startPage": 1,
      "endPage": 1,
      "classId": "string"
    }
  ],
  "classifyRunId": "clr_01K3F0000000000000000000",
  "materialize": true,
  "metadata": {
    "property1": null,
    "property2": null
  },
  "webhook": {
    "url": "http://example.com"
  },
  "ttl": 86400
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/v1/spaces/<spaceId>/split' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "file": {
    "url": "http://example.com",
    "name": "string",
    "processing": "auto"
  },
  "segments": [
    {
      "startPage": 1,
      "endPage": 1,
      "classId": "string"
    }
  ],
  "classifyRunId": "clr_01K3F0000000000000000000",
  "materialize": true,
  "metadata": {
    "property1": null,
    "property2": null
  },
  "webhook": {
    "url": "http://example.com"
  },
  "ttl": 86400
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/v1/spaces/<spaceId>/split';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    file: {url: 'http://example.com', name: 'string', processing: 'auto'},
    segments: [{startPage: 1, endPage: 1, classId: 'string'}],
    classifyRunId: 'clr_01K3F0000000000000000000',
    materialize: true,
    metadata: {property1: null, property2: null},
    webhook: {url: 'http://example.com'},
    ttl: 86400
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/v1/spaces/<spaceId>/split"

payload = {
    "file": {
        "url": "http://example.com",
        "name": "string",
        "processing": "auto"
    },
    "segments": [
        {
            "startPage": 1,
            "endPage": 1,
            "classId": "string"
        }
    ],
    "classifyRunId": "clr_01K3F0000000000000000000",
    "materialize": True,
    "metadata": {
        "property1": None,
        "property2": None
    },
    "webhook": { "url": "http://example.com" },
    "ttl": 86400
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

The finished run.

#### Example

```json
{
  "object": "split_run",
  "id": "string",
  "status": "queued",
  "expiresAt": "string",
  "statusUrl": "string",
  "files": [
    {
      "id": "string",
      "name": "string",
      "status": "string",
      "error": "string"
    }
  ],
  "file": {
    "id": "string",
    "name": "string",
    "status": "string",
    "error": "string"
  },
  "error": {
    "code": "string",
    "message": "string"
  },
  "metadata": {
    "property1": null,
    "property2": null
  },
  "usage": {
    "pages": 0,
    "parse": 0,
    "split": 0
  },
  "output": {
    "file": {
      "id": "string",
      "name": "string",
      "url": "string"
    },
    "files": [
      {
        "id": "string",
        "name": "string",
        "url": "string"
      }
    ],
    "classifyRunId": "string",
    "splits": [
      {
        "index": 0,
        "startPage": 0,
        "endPage": 0,
        "pageCount": 0,
        "classId": "string",
        "confidence": 0,
        "fileId": "string",
        "fileName": "string"
      }
    ],
    "documentIds": [
      "string"
    ]
  }
}
```

- `object` (`spaceSplit.response.200.object`; string, required)
- `id` (`spaceSplit.response.200.id`; string, required)
- `status` (`spaceSplit.response.200.status`; string, required) — Where the run is in its life. | Status | Meaning | | --- | --- | | `queued` | Accepted, not started | | `processing` | Work in flight | | `needs_input` | Waiting for an external action, such as an e-signature | | `processed` | Finished; `output` is populated | | `failed` | Finished unsuccessfully | | `cancelled` | Stopped on request | | `expired` | TTL elapsed and the data was purged | The last four are terminal.
  - one of `"queued"`, `"processing"`, `"processed"`, `"failed"`, `"cancelled"`, `"expired"`, `"needs_input"`
- `expiresAt` (`spaceSplit.response.200.expiresAt`; string | null, required)
- `statusUrl` (`spaceSplit.response.200.statusUrl`; string, required)
- `files` (`spaceSplit.response.200.files`; array<object>, required)
  - `id` (`spaceSplit.response.200.files.id`; string, required)
  - `name` (`spaceSplit.response.200.files.name`; string, required)
  - `status` (`spaceSplit.response.200.files.status`; string, required)
  - `error` (`spaceSplit.response.200.files.error`; string, optional)
- `file` (`spaceSplit.response.200.file`; object, optional)
  - `id` (`spaceSplit.response.200.file.id`; string, required)
  - `name` (`spaceSplit.response.200.file.name`; string, required)
  - `status` (`spaceSplit.response.200.file.status`; string, required)
  - `error` (`spaceSplit.response.200.file.error`; string, optional)
- `error` (`spaceSplit.response.200.error`; object, optional) — Why the run failed. Present whenever `status` is `failed`, and only then. `code` is the stable, snake_case reason (`input_unavailable`, `parse_failed`, …); `message` is the human-readable detail. Per-file and per-step failures are also reported in `files[].error` and, for a pipeline, `steps[].error`.
  - `code` (`spaceSplit.response.200.error.code`; string, required)
  - `message` (`spaceSplit.response.200.error.message`; string, required)
- `metadata` (`spaceSplit.response.200.metadata`; map<unknown>, optional)
- `usage` (`spaceSplit.response.200.usage`; object, optional)
  - `pages` (`spaceSplit.response.200.usage.pages`; number, optional)
  - `parse` (`spaceSplit.response.200.usage.parse`; number, optional)
  - `split` (`spaceSplit.response.200.usage.split`; number, optional)
- `output` (`spaceSplit.response.200.output`; object, optional) — The children. Present once `status` is `processed`. `splits[].fileId` is the authoritative id of each child, ready for `POST /v1/extract`; `documentIds[]` is the same list flattened. `classId` and `confidence` are echoed from whatever you supplied — split has no opinion about what a page is. With `materialize: false` the ranges come back with no `fileId`.
  - `files` (`spaceSplit.response.200.output.files`; array<object>, required)
    - `id` (`spaceSplit.response.200.output.files.id`; string, required)
    - `name` (`spaceSplit.response.200.output.files.name`; string, required)
    - `url` (`spaceSplit.response.200.output.files.url`; string, optional)
  - `file` (`spaceSplit.response.200.output.file`; object, optional)
    - `id` (`spaceSplit.response.200.output.file.id`; string, required)
    - `name` (`spaceSplit.response.200.output.file.name`; string, required)
    - `url` (`spaceSplit.response.200.output.file.url`; string, optional)
  - `classifyRunId` (`spaceSplit.response.200.output.classifyRunId`; string, optional)
  - `splits` (`spaceSplit.response.200.output.splits`; array<object>, optional)
    - `index` (`spaceSplit.response.200.output.splits.index`; number, required)
    - `startPage` (`spaceSplit.response.200.output.splits.startPage`; number, required)
    - `endPage` (`spaceSplit.response.200.output.splits.endPage`; number, required)
    - `pageCount` (`spaceSplit.response.200.output.splits.pageCount`; number, optional)
    - `classId` (`spaceSplit.response.200.output.splits.classId`; string, optional)
    - `confidence` (`spaceSplit.response.200.output.splits.confidence`; number, optional) — How sure the model was, 0–5. Route below 4 to a human; the label itself is never rewritten by a threshold.
    - `fileId` (`spaceSplit.response.200.output.splits.fileId`; string, optional)
    - `fileName` (`spaceSplit.response.200.output.splits.fileName`; string, optional)
  - `documentIds` (`spaceSplit.response.200.output.documentIds`; array<string>, optional)

### 202

Accepted — still running, or awaiting human input.

#### Example

```json
{
  "object": "string",
  "id": "string",
  "status": "queued",
  "statusUrl": "string",
  "envelopeUrl": "string"
}
```

- `object` (`spaceSplit.response.202.object`; string, required)
- `id` (`spaceSplit.response.202.id`; string, required)
- `status` (`spaceSplit.response.202.status`; string, required) — Where the run is in its life. | Status | Meaning | | --- | --- | | `queued` | Accepted, not started | | `processing` | Work in flight | | `needs_input` | Waiting for an external action, such as an e-signature | | `processed` | Finished; `output` is populated | | `failed` | Finished unsuccessfully | | `cancelled` | Stopped on request | | `expired` | TTL elapsed and the data was purged | The last four are terminal.
  - one of `"queued"`, `"processing"`, `"processed"`, `"failed"`, `"cancelled"`, `"expired"`, `"needs_input"`
- `statusUrl` (`spaceSplit.response.202.statusUrl`; string, required)
- `envelopeUrl` (`spaceSplit.response.202.envelopeUrl`; string, optional)

### 400

Invalid request (`segments_required`, `segments_conflict`, `invalid_segments`, `classify_run_mismatch`, `classify_run_not_paged`).

### 422

Unusable input file or webhook endpoint.

### 429

Rate limited. The `/v1` API allows at least **67 requests per minute per organization** (about 1,000 requests per 15 minutes) — a guaranteed floor, enforced per edge location, so a geographically spread caller may get more. Wait for the `Retry-After` interval and retry — the error is `retryable`.

#### Example

```json
{
  "code": "rate_limited",
  "message": "string",
  "retryable": true,
  "requestId": "string",
  "docUrl": "string"
}
```

- `code` (`spaceSplit.response.429.code`; string, required)
  - one of `"rate_limited"`
- `message` (`spaceSplit.response.429.message`; string, required)
- `retryable` (`spaceSplit.response.429.retryable`; boolean, required)
  - one of `true`
- `requestId` (`spaceSplit.response.429.requestId`; string, required)
- `docUrl` (`spaceSplit.response.429.docUrl`; string, optional)


Source: https://docs.cloudraker.com/paperwork/api/spaces/space-split/index.md
