> For the complete documentation index, see [llms.txt](https://docs.sypht.com/sypht/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sypht.com/sypht/workflows-v2/split.md).

# Smart document split (sypht.split)

{% hint style="info" %}
Split workflows are a `BETA` feature and subject to change.\
This guide is under-construction.
{% endhint %}

## How it works

In cases where a single PDF file contains multiple underlying documents, smart-split allows for the automatic detection and segmentation of sub-documents. Even in cases where sub-documents have variable lengths and format.

When a source file is uploaded, it is processed and a corresponding `fileId` is assigned. The `/results/` for the original file will then contain one or more child document `fileIds` which can be processed futher with the `sypht.validate` or `sypht.extract`workflows.

## Getting started

After uploading, invoke the sypht.split workflow

### 1. Invoke split workflow

POST /workflows/sypht.split/jobs

Request body:

{% code title="Sample" %}

```javascript
{
    "inputs":{
        "file_id":":00000000-0000-0000-0000-000000000000"
    }
}
```

{% endcode %}

#### Response:

```json
{
    "job": {
        "id": "", //uuid
        "company_id": "", //uuid
        "created": "2023-03-28T22:36:03.911887",
        "workflow_id": "", //worflowId 
        "inputs": {
            ...
            //key-value pairs of workflow inputs
        },
        "settings": {
            // key-value pair of your sypht settings
            ...
        },
        "usage": null,
        "file_id": "",
        "status": "new",
        "version": 3
    },
    "message_id": "" //uuid
}
```

### 2. Collect the split results

GET <https://api.sypht.com/result/final/00000000-0000-0000-0000-000000000000>

```javascript
{
    "fileId": "815c63f6-...-f07223d057cb",
    "status": "FINALISED",
    "results": {
        "fields": [
            {
                "name": "components.children",
                "value": [
                    {"file_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"},
                    {"file_id": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"}
                ]
            }
        ]
    }
}
```

### 3. Invoke workflows on each child document&#x20;

POST /workflows/sypht.extract/jobs

{% code title="Request body" %}

```json
{
    "inputs":{
        "file_id":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
        "product_ids":["ndis-claims:2"]
    }
}
```

{% endcode %}

### 4. Fetch results for child documents

GET /result/final/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa

{% code title="Response" %}

```javascript
{
    "fileId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
    "status": "FINALISED",
    "results": {
        "timestamp": "2020-08-20T03:30:09.703Z",
        "fields": [
            {
                "name": "invoice.total",
                "value": "1485.00",
                "confidence": 0.9958282699555642,
                ...
            },
            ...
        ]
    }
}
```

{% endcode %}

GET /result/final/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb

{% code title="Response" %}

```javascript
{
    "fileId": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
    "status": "FINALISED",
    "results": {
        "timestamp": "2020-08-20T03:30:09.703Z",
        "fields": [
            {
                "name": "invoice.total",
                "value": "2485.00",
                "confidence": 0.99582,
                ...
            },
            ...
        ]
    }
}
```

{% endcode %}

Limitations, Errors and Recommendations

* Uploading a document via the v2 upload endpoint avoids any of the downstream errors encountered with the v1 endpoint approach by enfocing page limits on all documents.  The default limit is 16 pages but this can be increased by request.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sypht.com/sypht/workflows-v2/split.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
