Docusure.AIIntelligent Document Workflow

Document Processing API

API Endpoint

POST
/api/resolvesync

Authentication

All API requests require authentication using a Bearer token in the Authorization header:

Authorization: Bearer YOUR_API_KEY
HTTP Header

Request Schema
FieldTypeRequiredDescription
idstring
Required
Unique request identifier for tracking
input.filestring
Required
Base64 encoded document file (PDF, PNG, JPG)
input.corpusNamestring
Required
Name of the corpus to use for processing
input.saveOODToRepositorystring
Optional
Repository identifier to save out-of-distribution (unknown) documents
input.metadataobject
Optional
Custom metadata to attach to the request
input.supervisionobject
Optional
Supervision data for training or evaluation
input.useThresholdsboolean
Optional
Enable unknown document detection using similarity thresholds (default: false)
callbackstring
Optional
URL for async callback (webhook)

Response Schema

{
  "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",
      "pageLayout": "invoice-standard-page1",
      "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
      }
    },
    {
      "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
      }
    }
  ]
}
JSON

Immediate Response:
{
  "status": "processed",
  "requestId": "request-123",
  "callbackUrl": "https://your-callback-url.com/webhook"
}
JSON
Webhook POST (sent to callback URL):

Same format as synchronous response above


Error Responses
Status CodeError TypeExample Response
401Unauthorized{"error": "Unauthorized: Invalid API key"}
400Bad Request{"error": {"requestId": "123", "message": "Missing required field: input.file"}}
500Server Error{"error": {"requestId": "123", "message": "Internal processing error"}}

Code Examples
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"
  }'
cURL

Unknown Document Detection
New Feature: Similarity Thresholds

Enable unknown document detection by setting input.useThresholds: true in your request.

When enabled, the system uses two-stage rejection:

  • Stage 1: Rejects documents with centroid similarity < 0.5
  • Stage 2: Rejects documents below class-specific thresholds (typically 0.92-1.0)

Unknown documents will have isUnknown: true with an explanation and nearest match information.


Processing Pipeline
How it works:
  1. Authentication - API key is validated against your organization

  2. Document Classification - Each page is analyzed and classified against known document layouts in your corpus

  3. Unknown Detection - When useThresholds is enabled, documents below similarity thresholds are marked as unknown

  4. Layout Matching - Pages are matched to specific layouts with similarity scores

  5. Entity Extraction - Based on the identified layout, relevant fields and entities are extracted

  6. Response Generation - Structured data is returned with bounding boxes and confidence scores

© 2025 Frank Sommers. All rights reserved.