Page Classify API
Name the class of a document, or of each of its pages, among the classes you give. Each classification runs in the background as a job: start it, then read it until it is done. Most take a few seconds.
For a walkthrough, see the Page Classify quick start.
Start a classification
POST /classify · WRITE key
Starts a job and returns 202 right away. Send one of your documents by its ID, or a PDF: the PDF is stored as a document of yours, as an upload with algorithm=none is, and only the classification is charged.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
configuration | string (form) | Yes | A JSON object. | |
doc_id | string (form) | Yes, or file | A completed document of yours. | |
file | file (form) | Yes, or doc_id | A PDF, kept as a document of yours. | |
collection_id | string (form) | No | With file: the collection the document goes in. | |
folder_id | string (form) | No | With file: the folder the document goes in. |
configuration holds:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
classes | array | Yes | 1 to 50 classes, each {"name": ..., "description": ...}. Names are unique; a description is optional. Names and descriptions hold at most 8,000 characters, all told. | |
granularity | string | No | document | document: one class for the document. page: a class for each page. |
target_pages | string | No | see below | One page or a range, such as 5 or 3-12, within the document. By default, document reads the first 5 pages and page reads every page. |
curl https://api.pageindex.ai/classify \
-H "Authorization: Bearer $PAGEINDEX_API_KEY" \
-F "file=@mixed.pdf" \
-F 'configuration={"classes": [{"name": "invoice", "description": "A bill asking for payment"}, {"name": "receipt"}], "granularity": "page"}'
{
"id": "cls_4b8e1d0a6c2f9e3b7a5d1c8e",
"status": "pending",
"doc_id": "pi-cm3k9x2qv0001l50856dh4a2f",
"configuration": {
"classes": [
{ "name": "invoice", "description": "A bill asking for payment" },
{ "name": "receipt" }
],
"granularity": "page",
"target_pages": "1-12"
},
"created_at": "2026-11-27T09:40:05",
"updated_at": "2026-11-27T09:40:05"
}
target_pages in the job names the pages it reads, defaulted or not.
The price is $0.001 a page read ($1 per 1,000 pages), for the pages classified. The amount is held when the job starts and charged when it completes. A job that fails isn't charged; a PDF sent with it is then left as a failed document. See Pricing.
| Status | When |
|---|---|
| 400 | A file that is not a PDF. |
| 402 | insufficient_credits: your balance does not cover the job. |
| 403 | The document is not yours, or a key below WRITE. |
| 404 | The document, collection or folder does not exist. |
| 409 | The document's pages are not ready yet. For a file stored already whose document is still processing, detail.doc_id names it. |
| 422 | Both doc_id and file, or neither. A configuration that is not valid: no classes, more than 50, two of one name, the name none of these, or more than 8,000 characters. A target_pages that is not valid. |
| 503 | The job could not be queued. Try again. |
SDK: PageClassifyClient.classify(), in Python.
Get a classification
GET /classify/{job_id} · READ key
Returns a job, with its result once it is completed.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
job_id | string (path) | Yes | The job's ID. |
curl https://api.pageindex.ai/classify/cls_4b8e1d0a6c2f9e3b7a5d1c8e \
-H "Authorization: Bearer $PAGEINDEX_API_KEY"
With granularity page:
{
"id": "cls_4b8e1d0a6c2f9e3b7a5d1c8e",
"status": "completed",
"doc_id": "pi-cm3k9x2qv0001l50856dh4a2f",
"configuration": {
"classes": [
{ "name": "invoice", "description": "A bill asking for payment" },
{ "name": "receipt" }
],
"granularity": "page",
"target_pages": "1-3"
},
"created_at": "2026-11-27T09:40:05",
"updated_at": "2026-11-27T09:40:09",
"finished_at": "2026-11-27T09:40:09",
"pages": [
{ "page": 1, "class": "invoice", "confidence": 0.98 },
{ "page": 2, "class": "invoice", "confidence": 0.97 },
{ "page": 3, "class": null, "confidence": 0.88 }
],
"failed_pages": [],
"usage": { "pages": 3, "credits": 0.3 }
}
With granularity document, the result is one class for the document in place of pages:
{
"class": "invoice",
"confidence": 0.95,
"failed_pages": [],
"usage": { "pages": 5, "credits": 0.5 }
}
classis one of your classes' names, ornullfor a page or document that is none of them.confidenceis the class's probability, from 0 to 1. For a document, it is averaged over the pages read.failed_pageslists pages that could not be read. They are left out of the result, and not charged.
status | What it means |
|---|---|
pending | Waiting to start. |
running | Reading and classifying the pages. |
completed | Done; the result is in the job. |
failed | Not done; error_message says why. Not charged. |
| Status | When |
|---|---|
| 404 | No job of yours has this ID. |