All API requests require authentication using a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Required | Unique request identifier for tracking |
input.file | string | Required | Base64 encoded document file (PDF, PNG, JPG) |
input.corpusName | string | Required | Name of the corpus to use for processing |
input.saveOODToRepository | string | Optional | Repository identifier to save out-of-distribution (unknown) documents |
input.metadata | object | Optional | Custom metadata to attach to the request |
input.supervision | object | Optional | Supervision data for training or evaluation |
input.useThresholds | boolean | Optional | Enable unknown document detection using similarity thresholds (default: false) |
callback | string | Optional | URL for async callback (webhook) |
{
"status": "OK",
"requestId": "request-123",
"timestamp": "2024-01-01T00:00:00.000Z",
"duration": "2.45",
"model": "gpt-4-vision",
"metadata": {},
"pages": [
{
"page": 1,
"documentType": "Invoice",
"documentTypeVariant": "Standard",
"documentTypeId": "52",
"documentTypeVariantId": "222",
"pageLayout": "invoice-standard-page1",
"pipelineId": "1",
"pipelineName": "Invoice Extraction",
"pipelineResult": {
"extraction": {
"invoice_number": "INV-2024-001",
"total_amount": 1250.5
},
"enhanced_image_png_base64": "BASE64_PNG"
},
"attributes": [
{
"item": "Invoice Number",
"text": "INV-2024-001",
"bbox_2d": [
100,
50,
250,
70
],
"namedEntity": "invoice_number"
}
],
"image_height": 1100,
"image_width": 850,
"matchInfo": {
"documentPageId": "layout-123",
"layoutId": "layout-123",
"maxSim": 0.95
},
"iclExamples": [
{
"documentPageId": "doc-456",
"layoutId": "layout-123",
"maxSim": 0.93,
"documentType": "Invoice",
"documentTypeVariant": "Standard",
"pageLayout": "invoice-standard-page1"
},
{
"documentPageId": "doc-789",
"layoutId": "layout-123",
"maxSim": 0.91,
"documentType": "Invoice",
"documentTypeVariant": "Standard",
"pageLayout": "invoice-standard-page1"
}
]
},
{
"page": 2,
"documentType": "unknown",
"documentTypeVariant": null,
"pageLayout": null,
"attributes": [],
"isUnknown": true,
"unknownReason": "Below class similarity threshold (0.42 < 0.65)",
"confidence": 0.42,
"nearestMatch": {
"documentType": "Receipt",
"similarity": 0.42
}
}
],
"pipelineSchemas": [
{
"documentTypeId": "52",
"documentType": "Invoice",
"documentTypeVariant": "Standard",
"pipelineId": "1",
"pipelineName": "Invoice Extraction",
"schema": "{...JSON schema text...}"
}
]
}{
"status": "processed",
"requestId": "request-123",
"callbackUrl": "https://your-callback-url.com/webhook"
}Same format as synchronous response above
| Status Code | Error Type | Example Response |
|---|---|---|
| 401 | Unauthorized | {"error": "Unauthorized: Invalid API key"} |
| 400 | Bad Request | {"error": {"requestId": "123", "message": "Missing required field: input.file"}} |
| 500 | Server Error | {"error": {"requestId": "123", "message": "Internal processing error"}} |
curl -X POST https://api.docugym.com/api/resolvesync \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "request-123",
"input": {
"file": "BASE64_ENCODED_FILE_CONTENT",
"corpusName": "your-corpus-name",
"saveOODToRepository": "my-repo-key",
"metadata": {
"source": "api-test",
"timestamp": "2024-01-01T00:00:00Z"
}
},
"callback": "https://your-callback-url.com/webhook"
}'Enable unknown document detection by setting input.useThresholds: true in your request.
When enabled, the system uses two-stage rejection:
Unknown documents will have isUnknown: true with an explanation and nearest match information.
When enabled for a corpus, the system automatically uses In-Context Learning (ICL) to improve entity extraction accuracy by providing the VLM with labeled examples from similar documents.
How it works:
iclExamples field in the response shows which examples were usedNote: The iclExamples field only appears in the response when ICL is enabled for the corpus and examples were successfully used.
Authentication - API key is validated against your organization
Document Classification - Each page is analyzed and classified against known document layouts in your corpus
Unknown Detection - When useThresholds is enabled, documents below similarity thresholds are marked as unknown
Layout Matching - Pages are matched to specific layouts with similarity scores
In-Context Learning - If enabled, the system selects up to 3 similar labeled examples from the corpus to improve extraction accuracy
Pipeline Extraction - When a pipeline is configured for a document type, the system invokes it to produce schema-compliant structured output for each page
Response Generation - Structured data is returned with pipeline results per page and the schema used for each document type (inpipelineSchemas)
© 2025 Frank Sommers. All rights reserved.