Limai Docs
API ReferenceClassification

Classify (Sync)

Classify a document synchronously and receive the routing result immediately.

POST/api/v1/classify/{classifierId}SYNC

Classify a document using AI-powered classification. The classifier analyzes the document and determines which model or deployment should be used for optimal data extraction. Returns the classification result immediately.

After classification, you must manually queue the extraction using the process-file-async endpoint with the returned fileId and extractionSchemaId.

The call is identical for project-scoped and global classifiers. With a global classifier the document may be routed to a deployment in another project of your organization, so resolve the returned extractionSchemaId rather than assuming the deployment is local.

Parameters

NameTypeInRequiredDescription
classifierIdstringpathYesThe classifier ID from your classifier settings.
fileIdstringbodyYesThe file ID returned from the classifier get-url endpoint after uploading.

Request

const response = await fetch(
`https://app.limai.io/api/v1/classify/${CLASSIFIER_ID}`,
{
  method: "POST",
  headers: {
    "Authorization": `Bearer ${API_TOKEN}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ fileId })
}
)
const result = await response.json()

Response

Classified Successfully

Response200
{
  "fileId": "file_abc123def456",
  "deploymentName": "Invoice Processing v2",
  "extractionSchemaId": "schema_789xyz012"
}
FieldTypeDescription
fileIdstringThe classified file ID. Use this with process-file to extract data.
deploymentNamestringHuman-readable name of the deployment the document was routed to.
extractionSchemaIdstringThe extraction schema ID of the routed model or deployment — not the deployment's own ID. Pass it to the process-file endpoints, which expect this ID.

Unclassified

When the document does not match any configured deployment routes:

Response200
{
  "fileId": null,
  "status": "UNCLASSIFIED"
}

Complete Workflow

const headers = { "Authorization": `Bearer ${API_TOKEN}` }

const urlRes = await fetch(
`https://app.limai.io/api/v1/classify/${CLASSIFIER_ID}/get-url?filename=doc.pdf`,
{ headers }
)
const { url, fileId } = await urlRes.json()

await fetch(url, {
method: "PUT",
headers: { "Content-Type": "application/pdf" },
body: fileData
})

const classifyRes = await fetch(
`https://app.limai.io/api/v1/classify/${CLASSIFIER_ID}`,
{
  method: "POST",
  headers: { ...headers, "Content-Type": "application/json" },
  body: JSON.stringify({ fileId })
}
)
const { extractionSchemaId, deploymentName } = await classifyRes.json()

await fetch(
`https://app.limai.io/api/v1/document/${extractionSchemaId}/process-file-async/${fileId}`,
{
  method: "POST",
  headers: { ...headers, "Content-Type": "application/json" },
  body: JSON.stringify({})
}
)

Webhooks

Every classification also fires the DOCUMENT_CLASSIFIED webhook, whether the document routed or came back unclassified. Subscribe to it if you want the decision pushed to you rather than read from the response.

On this page