Skip to content
Guide
Classify

Classify response format

Field-by-field reference for the Classify job response — the job envelope and statuses, the result object with the matched rule type, confidence score and reasoning, saved configurations, and how to collect results across many files.

A Classify job returns one object, the classify job, from POST /api/v2/classify, GET /api/v2/classify/{job_id}, and the cancel endpoint. The SDKs return the same object from client.classify.create(), client.classify.get(), client.classify.wait_for_completion(), and client.classify.run(). This page lists every field in that object and what each one means. For writing rules and running jobs, see Getting started; for the request side, see the Classify API reference.

FieldTypeDescription
idstringJob identifier. Pass it to GET /api/v2/classify/{job_id}.
statusstringJob state. See Job status.
file_inputstringThe file ID or parse job ID the job ran on.
document_input_typestringWhat file_input refers to: file_id, parse_job_id, or url.
parse_job_idstring or nullThe Parse job associated with this classification, if any.
configurationobjectThe configuration the job ran with: rules, mode, and parsing_configuration. Always present, whether the job was created inline or from a saved configuration.
configuration_idstring or nullSaved configuration ID used for the job, if any.
resultobject or nullThe classification. Present only when status is COMPLETED. See result.
error_messagestring or nullWhy the job failed, when status is FAILED.
transaction_idstring or nullThe idempotency key supplied at creation, if any. Reusing a key returns the original job.
project_idstringProject the job belongs to.
user_idstringUser who created the job.
created_at, updated_atdatetimeCreation and last-update timestamps.
statusMeaning
PENDINGQueued, not yet started.
RUNNINGActively processing.
COMPLETEDFinished; result is populated.
FAILEDTerminated with an error; result is null, read error_message.
CANCELLEDCancelled by the user; result is null.

Poll until the status is one of the three terminal values, or use client.classify.wait_for_completion(job.id). client.classify.run() creates the job and waits in one call, and raises if the job fails, so reaching the next line means it succeeded.

Each job classifies a single document and returns a single result with three fields:

FieldTypeDescription
typestring or nullThe type label of the rule that matched. Null when no rule matched.
confidencenumberConfidence that the match is correct, from 0.0 to 1.0.
reasoningstringWhy the document matched, or did not match, the returned rule.

type is always one of the type labels in configuration.rules (or null), so you can switch on it directly. Labels contain only alphanumeric characters, spaces, hyphens, and underscores; see Concepts.

From the contract classification example, which uses the rules affiliate_agreements and co_branding, the type and reasoning of a completed job read:

Classification Result: affiliate_agreements
Classification Reason: The document is titled 'MARKETING AFFILIATE AGREEMENT' and repeatedly refers to one party as the 'Marketing Affiliate.' The agreement outlines the rights and obligations of the 'Marketing Affiliate' (MA) to market, sell, and support certain technology products [...] Therefore, the best match is 'affiliate_agreements' with very high confidence.

Always check status (or result is None) before reading result: a failed or cancelled job has no result, and error_message carries the reason.

A job created with configuration_id runs with the rules, mode, and parsing configuration stored in that saved configuration. The response records both:

  • configuration_id echoes the saved configuration ID. It is null for jobs created with an inline configuration.
  • configuration is the resolved configuration the job ran with, so result.type can be matched against configuration.rules[].type even after the saved configuration has been edited.
  • A request may carry both configuration_id and an inline configuration. The inline fields you set override the saved values, and the fields you leave out fall through to the saved configuration; configuration in the response shows the merged result.

Updating a saved configuration changes future jobs that reference it; completed jobs keep the configuration they ran with. See Classify with a saved configuration.

One job classifies one document, so a batch of files produces one job per file. To collect the results:

  • Submit one job per file, with the same inline configuration or the same configuration_id, and read each job’s result.
  • GET /api/v2/classify returns a page of jobs as items, a next_page_token to fetch the next page (absent when there are no more pages), and an optional total_size. Filter by configuration_id, status, or job_ids to narrow the list. In the SDKs, client.classify.list(configuration_id=...) returns a cursor you can iterate directly; it fetches the following pages for you.
  • Pass a transaction_id on creation when you may retry a submission: reusing the key returns the original job instead of creating a second one.
import os
from llama_cloud import LlamaCloud
client = LlamaCloud(api_key=os.environ["LLAMA_CLOUD_API_KEY"])
file_obj = client.files.create(file="path/to/document.pdf", purpose="classify")
job = client.classify.create(
file_input=file_obj.id,
configuration={
"rules": [
{
"type": "invoice",
"description": "Documents that contain an invoice number, invoice date, bill-to section, and line items with totals.",
},
{
"type": "receipt",
"description": "Short purchase receipts, typically from POS systems, with merchant, items and total, often a single page.",
},
],
},
)
job = client.classify.wait_for_completion(job.id)
print(job.status)
print(job.document_input_type, job.file_input)
if job.result is None:
print(f"No result: {job.error_message}")
else:
print(job.result.type) # "invoice", "receipt", or None
print(job.result.confidence) # 0.0 to 1.0
print(job.result.reasoning)
Note for AI agents: this documentation is built for programmatic access. - Overview of all docs: https://developers.llamaindex.ai/llms.txt - Any page is available as raw Markdown by appending index.md to its URL — e.g. https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md - Agent-friendly REST search APIs live under https://developers.llamaindex.ai/api/ — search (BM25 full-text), grep (regex), read (fetch a page), and list (browse the doc tree). See https://developers.llamaindex.ai/llms.txt for parameters. - A hosted documentation MCP server is available at https://developers.llamaindex.ai/mcp. If you support MCP, you can ask the user to install it for browsing these docs directly (an alternative to the REST API). Setup: https://developers.llamaindex.ai/for-agents/mcp/ - Other LlamaIndex tooling for agents — the LlamaParse Platform MCP server, agent skills and plugins, and the n8n node — is mapped at https://developers.llamaindex.ai/for-agents/