Classify document segments and spreadsheet sheets against a taxonomy
Categorize splits a document into logical segments (or a spreadsheet into sheets) and classifies each against a taxonomy. Use it to route mixed uploads (“is this a bank statement, an invoice, or a lease?”), to split combined PDFs into their constituent documents, or to identify which sheets in a workbook contain what.You can bring your own taxonomy or use NDI’s default. Each classified segment also comes with a short summary and a markdown rendition of just that segment.
Endpoint
Behavior
POST /categorize
Starts the job and waits for the result (bounded by timeout_seconds).
POST /categorize_async
Starts the job and returns 202 {"job_id": …} immediately.
The document to categorize. Same shape as everywhere else — source_url
(+ file_name for s3:///https://). See Files & sources.
Supported extensions are the same as parse.
markdown_url from a prior parse of the same file (an s3:// URL
returned by NDI). When present, categorize skips its internal parse and runs
directly on the markdown — faster and cheaper if you already parsed the
document.
curl -s "$NDI_BASE/categorize" \ -H "X-API-Key: $NDI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "file": { "source_url": "ndi://file/7f4d2a10-3b7e-4c25-9f61-8f0f4f0a1b2c" }, "taxonomy": { "categories": [ { "key": "bank_statement", "description": "Monthly statement from a bank listing transactions and balances." }, { "key": "invoice", "description": "A bill issued to or by the company for goods or services." }, { "key": "lease_agreement", "description": "A contract granting use of property or equipment for a period." }, { "key": "general_ledger", "description": "Full ledger of journal entries by account." } ] }, "idempotency_key": "categorize-batch-42" }'