Documentation /docs/classify-split

Classify & Split

Use Classify when you need a routing label. Use Split when a packet contains multiple documents and you need inferred document boundaries plus reusable child file references.

Classify request

{
  "input": {"file_id": "file_packet"},
  "execution_mode": "sync",
  "classification_scope": "document",
  "class_definitions": [
    {"label": "invoice", "description": "Supplier invoice requesting payment"},
    {"label": "purchase_order", "description": "Buyer purchase authorization"}
  ]
}

Split request

{
  "input": {"file_id": "file_packet"},
  "execution_mode": "sync",
  "verbosity": "none"
}

cURL

curl -sS -X POST "https://api.docspeed.ai/v1/classify" \
  -H "Authorization: Bearer ${DOCSPEED_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {"file_id": "file_packet"},
    "execution_mode": "sync",
    "classification_scope": "page",
    "class_definitions": [
      {"label": "invoice", "description": "Supplier invoice requesting payment"},
      {"label": "purchase_order", "description": "Buyer purchase authorization"},
      {"label": "delivery_note", "description": "Proof of delivery or receiving document"}
    ]
  }'

Python

import requests

response = requests.post(
    "https://api.docspeed.ai/v1/split",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={
        "input": {"file_id": "file_packet"},
        "execution_mode": "sync",
        "verbosity": "none",
    },
    timeout=600,
)
response.raise_for_status()
print(response.json())

TypeScript

const response = await fetch("https://api.docspeed.ai/v1/classify", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    input: { file_id: "file_packet" },
    execution_mode: "sync",
    classification_scope: "document",
    class_definitions: [
      { label: "invoice", description: "Supplier invoice requesting payment" },
      { label: "purchase_order", description: "Buyer purchase authorization" },
    ],
  }),
});

console.log(await response.json());

Example Classify response fragment

{
  "doc_class": "invoice",
  "input_type": "auto",
  "page_count": 2,
  "page_classifications": [
    {"page_index": 0, "doc_class": "invoice", "confidence": 0.94},
    {"page_index": 1, "doc_class": "invoice", "confidence": 0.91}
  ]
}

Example Split response fragment

{
  "total_pages": 5,
  "documents": [
    {
      "start_page": 0,
      "end_page": 1,
      "doc_class": "purchase_order",
      "title": "Purchase order",
      "confidence": 0.92,
      "file_ref": {"file_id": "file_child_po", "filename": "packet-part-1.pdf", "size_bytes": 104812, "created_at": 1776054000.0}
    },
    {
      "start_page": 2,
      "end_page": 4,
      "doc_class": "invoice",
      "title": "Supplier invoice",
      "confidence": 0.9,
      "file_ref": {"file_id": "file_child_invoice", "filename": "packet-part-2.pdf", "size_bytes": 205781, "created_at": 1776054001.0}
    }
  ]
}

Production notes

  • Use classification_scope: "document" for one routing label per uploaded file.
  • Use classification_scope: "page" when pages may belong to different document types.
  • Split returns contiguous page segments. Reuse returned child file_id values downstream instead of re-uploading split files.