Get Classifier Upload URL
Get a pre-signed URL for uploading files to be classified.
/api/v1/classify/{classifierId}/get-urlRequest a pre-signed URL for uploading files that need to be classified. Returns both the upload URL and a file ID that you will use in the classification request.
The endpoint works the same way for project-scoped and global classifiers.
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
classifierId | string | path | Yes | The classifier ID. Found in your classifier settings in the platform. |
filename | string | query | Yes | The original filename of the document to classify. |
contentHash | string | query | No | SHA-256 of the file's bytes, lowercase hex. Turns on duplicate detection; without it every request creates a new file. |
allowDuplicate | boolean | query | No | Set to true to skip duplicate detection and always create a new file, which is how you re-classify the same bytes on purpose. Omitting it is the same as false. |
Duplicate Detection
Detection is scoped to this classifier: it looks for a file already sent to the same classifier whose content hash matches. "Same file" means the same bytes, not the same name — a renamed copy of a document you already sent is a duplicate, and two different documents that share a filename are not.
Detection only runs when you send contentHash. Compute the SHA-256 of the bytes you are about to upload and pass it as lowercase hex; the platform never hashes the content for you on this path.
On a match no new file is created. The response carries the existing file's fileId, isDuplicate is true, url is an empty string, and classification carries the latest verdict that classifier reached for that file:
{
"url": "",
"fileId": "file_abc123def456",
"isDuplicate": true,
"existingFileId": "file_abc123def456",
"classification": {
"classificationId": "cls_456def",
"status": "CLASSIFIED",
"deploymentName": "Invoice Processing v2",
"extractionSchemaId": "schema_789xyz012",
"modelId": "dep_123abc",
"classifiedAt": "2024-01-15T10:31:05Z"
}
}When url is empty, do not upload. There is nothing to PUT: the bytes are already stored. Skip the upload and continue with the returned fileId.
classification is null when the matching file was uploaded but never classified. Otherwise it describes the most recent classification run for that file in this classifier:
| Field | Type | Description |
|---|---|---|
classificationId | string | The classification run. Read it back with the status endpoint. |
status | string | CLASSIFIED, UNCLASSIFIED, PROCESSING, or FAILED. |
deploymentName | string | null | Human-readable name of the deployment the document was routed to. null unless the status is CLASSIFIED. |
extractionSchemaId | string | null | The extraction schema ID of the routed model or deployment. null unless the status is CLASSIFIED. |
modelId | string | null | The routed model's own ID. null unless the status is CLASSIFIED. |
classifiedAt | string | ISO timestamp of the run. |
What to do next depends on classification.status:
CLASSIFIED— you already have the verdict. Skip the classify call and go straight to process-file with the returnedfileIdandextractionSchemaId.- Anything else, or
classification: null— call classify with the returnedfileId. A file whose latest verdict isUNCLASSIFIEDis re-run, so re-sending it after adding a route works.
With allowDuplicate=true the lookup is skipped and a genuine second file is created, with a new fileId, a pre-signed upload URL, and isDuplicate set to false. That is the way to force a fresh classification run on bytes that were already classified.
The file ID is stable through routing: when the classifier routes a document, the same file row moves to the routed model, so the fileId this endpoint returns is the id the document endpoints use for that document afterwards.
Request
import { createHash } from "node:crypto"
const contentHash = createHash("sha256").update(fileData).digest("hex")
const response = await fetch(
`https://app.limai.io/api/v1/classify/${CLASSIFIER_ID}/get-url?filename=${filename}&contentHash=${contentHash}`,
{
headers: { "Authorization": `Bearer ${API_TOKEN}` }
}
)
const { url, fileId, isDuplicate, classification } = await response.json()
if (!isDuplicate) {
await fetch(url, {
method: "PUT",
headers: { "Content-Type": "application/pdf" },
body: fileData
})
}Response
{
"url": "https://s3.amazonaws.com/bucket/path?AWSAccessKeyId=...",
"fileId": "abc123def456",
"isDuplicate": false
}Response Fields
| Field | Type | Description |
|---|---|---|
url | string | Pre-signed URL for uploading the file. Temporary and expires after a short period. Empty when the content is a duplicate. |
fileId | string | Unique file identifier. Use this in the classification request after uploading. For a duplicate, the identifier of the file the classifier already holds. |
isDuplicate | boolean | Whether these bytes were already sent to this classifier. Always false when you send no contentHash. |
existingFileId | string | The matched file's identifier, same value as fileId. Returned with a duplicate. |
classification | object | null | The latest verdict for the matched file, or null when it was never classified. Returned with a duplicate. |
Next Steps
After receiving the upload URL:
- Upload your file to the pre-signed URL using a PUT request, unless
urlis empty - Classify the document using sync classification or async classification