POST /documents/{action}

action is classify or split. JSON body. These routes work on text that has already been recognized: send the recognized text of each page, for example from an OCR run. Authentication: X-API-Key: <key> or Authorization: Bearer <key> header.

POST /documents/{action}

Request body

The following parameters can be included in the request body:

Parameters

action
string
Required

Path. classify or split.

page_texts
array<string>
Required

Text of each page, in order. 100 pages at most.

labels
array<string> array<object>

Categories: list of names, or list of {name, description} objects. Required for classify. 255 maximum; the name "none" is reserved (no category).

threshold
integer
Default value: 50

split only. Split threshold between two pages, from 0 to 100.

Successful response

The following fields are returned in a successful response:

Response fields

ok
boolean
Required

true if the request succeeded.

page_count
integer
Required

Number of pages analyzed.

documents
array<object>

split. One object per document: index, start_page, end_page, page_range, page_count, confidence and, if labels are provided, classification.

boundaries
array<object>

split. For each boundary between pages: after_page and new_document_probability.

label
string

classify. Category selected (or none).

confidence
number

classify. Confidence of the selected category.

probabilities
object

classify. Probability of each category, none included.

threshold
integer

split. Threshold applied.

timings
object

Processing times (total_ms).

Examples

Code examples for using this endpoint:

curl
curl -X POST https://api-endpoints.alphaedge-ai.com/documents/split \
  -H "X-API-Key: $ALPHAEDGE_API_KEY" -H "Content-Type: application/json" \
  -d '{"page_texts": ["Invoice no. 1 …", "Invoice continued …", "Lease agreement …"],
       "labels": [{"name": "invoice", "description": "Invoice"}, {"name": "contract"}],
       "threshold": 50}'

Response

Sample API response:

json
{
  "ok": true,
  "page_count": 4,
  "threshold": 50,
  "documents": [
    { "index": 0, "start_page": 1, "end_page": 2, "page_range": "1-2", "page_count": 2, "confidence": 0.91,
      "classification": { "label": "invoice", "confidence": 0.86, "probabilities": { "invoice": 0.86, "none": 0.02 } } },
    { "index": 1, "start_page": 3, "end_page": 4, "page_range": "3-4", "page_count": 2, "confidence": 0.91 }
  ],
  "boundaries": [
    { "after_page": 1, "new_document_probability": 0.08 },
    { "after_page": 2, "new_document_probability": 0.91 },
    { "after_page": 3, "new_document_probability": 0.07 }
  ],
  "timings": { "total_ms": 1260 }
}

classify response

json
{
  "ok": true,
  "page_count": 3,
  "label": "invoice",
  "confidence": 0.86,
  "probabilities": { "invoice": 0.86, "contract": 0.1, "none": 0.02 },
  "timings": { "total_ms": 1260 }
}

Errors

422 invalid_param (invalid page_texts or labels), 422 limit_exceeded, 503 model_unavailable, 504 model_timeout. The announced limits are in documents of GET /pipelines/capabilities.