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.

NameTypeRequiredDefaultDescription
configurationstring (form)YesA JSON object.
doc_idstring (form)Yes, or fileA completed document of yours.
filefile (form)Yes, or doc_idA PDF, kept as a document of yours.
collection_idstring (form)NoWith file: the collection the document goes in.
folder_idstring (form)NoWith file: the folder the document goes in.

configuration holds:

NameTypeRequiredDefaultDescription
classesarrayYes1 to 50 classes, each {"name": ..., "description": ...}. Names are unique; a description is optional. Names and descriptions hold at most 8,000 characters, all told.
granularitystringNodocumentdocument: one class for the document. page: a class for each page.
target_pagesstringNosee belowOne 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.

StatusWhen
400A file that is not a PDF.
402insufficient_credits: your balance does not cover the job.
403The document is not yours, or a key below WRITE.
404The document, collection or folder does not exist.
409The document's pages are not ready yet. For a file stored already whose document is still processing, detail.doc_id names it.
422Both 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.
503The 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.

NameTypeRequiredDefaultDescription
job_idstring (path)YesThe 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 }
}
  • class is one of your classes' names, or null for a page or document that is none of them.
  • confidence is the class's probability, from 0 to 1. For a document, it is averaged over the pages read.
  • failed_pages lists pages that could not be read. They are left out of the result, and not charged.
statusWhat it means
pendingWaiting to start.
runningReading and classifying the pages.
completedDone; the result is in the job.
failedNot done; error_message says why. Not charged.
StatusWhen
404No job of yours has this ID.