Skip to main content

API Examples

Extraction Request

curl -X POST "https://api.example.com/document/get-extraction" \
-H "Authorization: Bearer <access-token-or-api-key>" \
-H "Content-Type: application/json" \
-d '{
"documentId": "example-document-id",
"templateId": "example-template-id"
}'

Classification Request

curl -X POST "https://api.example.com/document/get-classifier" \
-H "Authorization: Bearer <access-token-or-api-key>" \
-H "Content-Type: application/json" \
-d '{
"documentId": "example-document-id"
}'

Response Parsing

caution

Some xTrakt backend responses are returned with Content-Type: text/plain while the body contains JSON. API clients should parse the response body as JSON even when the content type is not application/json.

async function parseXtraktResponse<T>(response: Response): Promise<T> {
const body = await response.text();
const parsed = JSON.parse(body) as T;

if (!response.ok) {
throw new Error(`xTrakt request failed with status ${response.status}`);
}

return parsed;
}