Extract Document

POST /workspaces/{slug}/schemas/{schemaKey}/extract

Two modes of document resolution: 1. Existing document: Provide documentId to extract from a previously uploaded document. 2. Inline upload: Provide name + content (JSON) or name + file (multipart) to create a new document and extract in one request. Two modes of schema resolution: A. Use schemaKey from URL path to resolve the latest (or specific) version. B. Provide schema in body to auto-version (creates family/version if needed). Returns 202 with a runId. Poll GET /runs/{runId} for results.

Path Parameters

slug: string required
schemaKey: string required

Query Parameters

env: "production" | "staging" | "development"

Environment slug. Defaults to production.

Body Parameters

documentId: string

ID of an existing document to extract from

versionNumber: integer
schema: object
schemaName: string

Display name for the schema family

description: string

Description for the schema family

name: string

Document name (for inline upload without documentId)

content: string

Document content (for inline upload without documentId)

model: string

Optional provider/model override for this run. Format is provider/model — for example anthropic/claude-opus-4-7. Takes precedence over the environment assignment. Returns 412 no_key if the named provider has no user key and is not Mistral.


            curl -X POST \
-H "x-api-key: dsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"documentId": "doc_abc123",
"versionNumber": 1,
"schema": {},
"schemaName": "example-schemaName",
"description": "Invoice processing workspace",
"name": "My Workspace",
"content": "Invoice #1234...",
"model": "example-model"
}' \
https://api.tracore.io/workspaces/my-workspace/schemas/invoice/extract?env=production
          

            import { TracoreClient } from '@tracore/sdk';

const client = new TracoreClient({ apiKey: 'dsk_your_api_key' });

// Extract from existing document with auto-polling
const run = await client.extract('my-workspace', 'invoice', {
documentId: 'doc_abc123',
}, { poll: true });

if (run.status === 'completed') {
console.log(run.extractedData);
}
          
202 Response
{
  "runId": "run_abc123",
  "status": "pending"
}