POST /document/classifier
Classifies one or more uploaded documents against the document types configured for your tenant in the xTrakt platform. Useful when you receive a batch of files and need to know what each one is before routing it to the right downstream flow.
📷 Paste here: screenshot of the Document Types configuration screen on the platform, so the reader sees which labels the classifier can return.
Endpoint​
POST https://api-dev.xtrakt.ai/document/classifier
Authentication​
Send your API key as a Bearer token. See Getting Started for how to generate one.
Authorization: Bearer xtkt_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Request​
Content-Type: multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
files | file (repeatable) | ✅ | One or more files to classify. Repeat the files field for each file you want to send in the same call. |
Constraints
- Allowed extensions:
.pdf,.png,.jpg,.jpeg,.tiff,.tif,.bmp,.doc,.docx. - Max size per file: 10 MB.
- Rate limit: 50 requests/minute per API key.
Response​
200 OK — the response envelope wraps a list with one entry per uploaded file, in the same order they were sent:
{
"data": {
"results": [
{
"fileName": "invoice-001.pdf",
"documentType": "Invoice",
"confidence": 0.97
},
{
"fileName": "id-card.jpg",
"documentType": "Identity Document",
"confidence": 0.91
}
]
},
"meta": { "httpStatusCode": 200, "messages": [] },
"hasErrors": false
}
Example — curl​
curl -X POST "https://api-dev.xtrakt.ai/document/classifier" \
-H "Authorization: Bearer xtkt_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-F "files=@./invoice-001.pdf" \
-F "files=@./id-card.jpg"
Example — Python​
import requests
API_KEY = "xtkt_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
BASE_URL = "https://api-dev.xtrakt.ai"
files = [
("files", ("invoice-001.pdf", open("invoice-001.pdf", "rb"), "application/pdf")),
("files", ("id-card.jpg", open("id-card.jpg", "rb"), "image/jpeg")),
]
response = requests.post(
f"{BASE_URL}/document/classifier",
headers={"Authorization": f"Bearer {API_KEY}"},
files=files,
)
response.raise_for_status()
print(response.json()["data"]["results"])
Example — Node.js​
import fs from "node:fs";
const API_KEY = "xtkt_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const BASE_URL = "https://api-dev.xtrakt.ai";
const form = new FormData();
form.append("files", new Blob([fs.readFileSync("./invoice-001.pdf")]), "invoice-001.pdf");
form.append("files", new Blob([fs.readFileSync("./id-card.jpg")]), "id-card.jpg");
const response = await fetch(`${BASE_URL}/document/classifier`, {
method: "POST",
headers: { Authorization: `Bearer ${API_KEY}` },
body: form,
});
const { data } = await response.json();
console.log(data.results);
Errors​
| HTTP status | Reason |
|---|---|
400 Bad Request | No file was sent, a file is empty, has a disallowed extension, or exceeds 10 MB. |
401 Unauthorized | Missing/invalid/revoked API key. |
403 Forbidden | Tenant has no active subscription for classification. |
429 Too Many Requests | API key exceeded the 50 req/min limit. |