Classify (Sync)
Classify a document synchronously and receive the routing result immediately.
/api/v1/classify/{classifierId}SYNCClassify a document using AI-powered classification. The classifier analyzes the document and determines which model 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 model in another project of your organization, so resolve the returned extractionSchemaId rather than assuming the model is local.
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
classifierId | string | path | Yes | The classifier ID from your classifier settings. |
fileId | string | body | Yes | The 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
{
"fileId": "file_abc123def456",
"deploymentName": "Invoice Processing v2",
"extractionSchemaId": "schema_789xyz012"
}| Field | Type | Description |
|---|---|---|
fileId | string | The classified file ID. Use this with process-file to extract data. |
deploymentName | string | Human-readable name of the model the document was routed to. |
extractionSchemaId | string | The routed model's extraction schema ID, or the model's own ID when it has no legacy extraction schema. Pass it to the process-file endpoints. |
When the chosen route targets one of the model's deployments, the file is stamped with that deployment, and process-file addressed to the returned extractionSchemaId extracts it through the deployment — its pinned version and pause apply.
Unclassified
When the document does not match any of the classifier's routes, or every route that fits it targets a paused deployment:
{
"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.