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 extraction schema (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.

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 to use for processing.

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({})
}
)