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 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
| 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 deployment the document was routed to. |
extractionSchemaId | string | The 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:
{
"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.