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.
/documents/{action}
Request body
The following parameters can be included in the request body:
Parameters
action
Path. classify or split.
page_texts
Text of each page, in order. 100 pages at most.
labels
Categories: list of names, or list of {name, description} objects. Required for classify. 255 maximum; the name "none" is reserved (no category).
threshold
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
true if the request succeeded.
page_count
Number of pages analyzed.
documents
split. One object per document: index, start_page, end_page, page_range, page_count, confidence and, if labels are provided, classification.
boundaries
split. For each boundary between pages: after_page and new_document_probability.
label
classify. Category selected (or none).
confidence
classify. Confidence of the selected category.
probabilities
classify. Probability of each category, none included.
threshold
split. Threshold applied.
timings
Processing times (total_ms).
Examples
Code examples for using this endpoint:
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:
{
"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
{
"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.