# Document Extraction Model

*/Software/Document_Extraction_Model*

## Solution Overview

The Document Extraction Model processes unstructured commercial PDFs, scanned forms, and photographed receipts, converting them into validated, deterministic JSON payloads. It maps raw text blocks and tabular data to pre-defined database schemas using spatial layout analysis. The output is a structured dataset containing extracted key-value pairs, nested line items, and bounding-box coordinates for auditability, complete with field-level confidence scores.

Backend developers and automation engineers at logistics firms and commercial lenders integrate this API to bypass brittle, template-based OCR systems. Instead of writing custom parsing scripts for every new bill of lading or vendor invoice layout, engineering teams pass the raw file and a target schema to the endpoint. The model resolves variations in document structure, removing the maintenance overhead of updating regular expressions when a supplier changes their formatting.

Operating strictly as a Headless SaaS primitive, the model ingests raw file streams from cloud storage buckets or incoming webhook payloads. It is consumed by higher-level accounting agents and enterprise resource planning systems that require structured data to execute transactions. For extracted fields falling below a defined confidence threshold, the API routes the isolated bounding-box image to a human-in-the-loop validation queue before returning the finalized payload to the client application.

## Headless Saas Data Model

**Entities**:
- Name: Document · Description: The raw file submitted for data extraction and structured parsing.
- Name: Workspace · Description: The top-level tenant isolating schemas and documents per customer account.
- Name: ExtractionSchema · Description: The target layout mapping defining which fields to extract from documents.
- Name: SchemaField · Description: An individual target key or nested line item to locate during extraction.
- Name: ExtractedValue · Description: A structured data point extracted from a document with confidence scoring.
- Name: ValidationTask · Description: A human-in-the-loop review item for low-confidence extracted data values.
**Relations**:
- To: Document · From: Workspace · Label: owns documents · Cardinality: one-to-many
- To: ExtractionSchema · From: Workspace · Label: owns schemas · Cardinality: one-to-many
- To: Document · From: ExtractionSchema · Label: structures · Cardinality: one-to-many
- To: SchemaField · From: ExtractionSchema · Label: defines fields for · Cardinality: one-to-many
- To: ExtractedValue · From: Document · Label: yields · Cardinality: one-to-many
- To: ExtractedValue · From: SchemaField · Label: maps to · Cardinality: one-to-many
- To: ValidationTask · From: ExtractedValue · Label: requires review via · Cardinality: one-to-one
**Tenant Anchor**: Workspace
**Primary Resource**: Document

## Api Definition

**Protocols**:
- REST
- SDK
- Webhooks
- MCP
**Consumed By**:
- [Accounts Payable Agent](/Agents/Accounts_Payable_Agent)
- [Logistics Triage Agent](/Agents/Logistics_Triage_Agent)
- [Commercial Underwriting Agent](/Agents/Commercial_Underwriting_Agent)
**Integrations**:
- [AWS S3](/Products/AWS_S3)
- [Google Cloud Storage](/Products/Google_Cloud_Storage)
- [NetSuite](/Products/NetSuite)
- [SAP](/Products/SAP)
**Consumption Model**: An agent registers the tool via MCP, submits a raw file via REST, and subscribes to an extraction.completed webhook for the validated JSON payload.
**Workflow Wrappers**:
- Name: Submit Document Payload · Wraps: Ingests the file, maps schema fields, and queues low-confidence values for HITL review.
- Name: Register Target Schema · Wraps: Builds an extraction schema and nested schema fields for spatial layout mapping.
- Name: Commit Manual Resolution · Wraps: Saves human input and compiles the finalized JSON document payload for downstream systems.

## Api Function Cascade

**Ai Role**: Generative AI extracts spatial and semantic field values straight-through against the registered schema, requiring human intervention strictly on exception when confidence thresholds fall below predefined limits.
**Cascade**:
- Kind: Code · Note: Fetches the raw document payload from the REST API or cloud storage integrations. · Step: Ingest Document File · Verb: ingest · Realizes: Process Inbound Files · Oversight: none
- Kind: Generative · Note: Reads document spatial layouts and extracts values, flagging low-confidence reads for review. · Step: Extract Schema Fields · Verb: extract · Realizes: Extract Document Information · Oversight: review-on-exception
- Kind: Code · Note: Validates types, enforces schema definitions, and integrates committed manual resolutions. · Step: Normalize Extracted Values · Verb: normalize · Realizes: Format Structured Data · Oversight: none
- Kind: Code · Note: Fires the extraction.completed webhook to notify consuming agents and updates ERP systems. · Step: Dispatch JSON Payload · Verb: dispatch · Realizes: Transmit System Messages · Oversight: none
**Optimizes**:
- [Field Extraction Accuracy](/Metrics/Field_Extraction_Accuracy)
- [Straight-Through Processing Rate](/Metrics/Straight-Through_Processing_Rate)
- [Document Processing Latency](/Metrics/Document_Processing_Latency)
- [Exception Resolution Time](/Metrics/Exception_Resolution_Time)

## Headless Saas Representative Offer

**Warranty**: Commits to a 99.9% API uptime SLA, providing prorated service credits for missed availability targets or dropped webhook events.
**Price Band**: ~$0.02 to $0.10 per processed document page, depending on schema complexity and overall volume.
**Pricing Kind**: UsageMeter
**Deliverables**:
- JSON extraction payloads mapped to registered target schemas
- Field-level confidence scores and spatial bounding box coordinates
- Programmatic access to human-in-the-loop resolution queues
- Automated webhook notifications for completed processing jobs
**Delivery Mode**: Self-serve provisioning grants immediate API and MCP tool access, allowing agents to submit raw files and receive metered, asynchronous payload deliveries via webhooks.
**Business Function**: ProvideService
**Agent Checkout Support**:
- agentic-commerce-protocol
- stored-credential

## Headless Saas Crud Surface

**Auth Model**: API Key
**Endpoints**:
- GET /documents — list documents
- POST /documents — upload a document for extraction
- GET /documents/{id} — fetch document details
- PATCH /documents/{id} — update document metadata
- GET /workspaces — list workspaces
- POST /workspaces — create a new workspace
- GET /workspaces/{id} — fetch a workspace
- PATCH /workspaces/{id} — update workspace configuration
- GET /workspaces/{id}/documents — list documents owned by a workspace
- GET /workspaces/{id}/extraction-schemas — list schemas owned by a workspace
- GET /extraction-schemas — list extraction schemas
- POST /extraction-schemas — create a new extraction schema
- GET /extraction-schemas/{id} — fetch extraction schema details
- PATCH /extraction-schemas/{id} — update an extraction schema
- GET /extraction-schemas/{id}/schema-fields — list fields defined for a schema
- POST /extraction-schemas/{id}/schema-fields — append a field definition to a schema
- GET /schema-fields/{id} — fetch schema field details
- PATCH /schema-fields/{id} — update a schema field configuration
- GET /documents/{id}/extracted-values — list structured data yielded by a document
- POST /documents/{id}/extracted-values — insert a parsed value for a document
- GET /extracted-values/{id} — fetch a single extracted value and its bounding box
- PATCH /extracted-values/{id} — update an extracted value
- GET /extracted-values/{id}/validation-tasks — fetch the review task required for a low-confidence value
- GET /validation-tasks — list pending validation tasks
- POST /validation-tasks — create a new validation task
- GET /validation-tasks/{id} — fetch a validation task
- PATCH /validation-tasks/{id} — update validation task status
- POST /validation-tasks/{id}/resolve — commit a human-reviewed resolution to a task
**Multitenancy**: Row-level isolation
**Webhook Events**:
- document.processed
- document.failed
- validation_task.created
- validation_task.resolved

## Headless Saas Erd

```mermaid
erDiagram
    Workspace {
        UUID id PK "tenant key"
        VARCHAR name
        TIMESTAMP createdAt
    }
    Document {
        UUID id PK
        UUID workspaceId FK
        UUID schemaId FK
        VARCHAR fileUrl
        VARCHAR status
        TIMESTAMP processedAt
    }
    ExtractionSchema {
        UUID id PK
        UUID workspaceId FK
        VARCHAR name
        BOOLEAN isActive
    }
    SchemaField {
        UUID id PK
        UUID schemaId FK
        VARCHAR keyName
        VARCHAR dataType
        BOOLEAN isLineItem
    }
    ExtractedValue {
        UUID id PK
        UUID documentId FK
        UUID fieldId FK
        JSONB parsedValue
        DECIMAL confidenceScore
        JSONB boundingBox
    }
    ValidationTask {
        UUID id PK
        UUID extractedValueId FK
        VARCHAR snippetImageUrl
        VARCHAR status
        JSONB resolvedValue
    }
    Workspace ||--o{ Document : "owns documents"
    Workspace ||--o{ ExtractionSchema : "owns schemas"
    ExtractionSchema ||--o{ Document : "structures"
    ExtractionSchema ||--o{ SchemaField : "defines fields for"
    Document ||--o{ ExtractedValue : "yields"
    SchemaField ||--o{ ExtractedValue : "maps to"
    ExtractedValue ||--|| ValidationTask : "requires review via"
```

## Neighborhood

### Composed into

- [Tax Data Service](/Services/Tax_Data_Service) — composes · Services
- [Recall Orchestration Agent](/Agents/Recall_Orchestration_Agent) — composes · Agents
- [Payables Processing Agent](/Agents/Payables_Processing_Agent) — composes · Agents
- [Sponsorships](/Services/Sponsorships) — composes · Services
- [Public affairs service](/Services/Public_affairs_service) — composes · Services
- [Ledger Intake Agent](/Services/Ledger_Intake_Agent) — composes · Services
- [Export administration and accounting service](/Services/Export_administration_and_accounting_service) — composes · Services
- [Accounting services](/Services/Accounting_services) — composes · Services

### What it uses

- [Sap](/Products/Sap) — uses · Products
- [NetSuite](/Software/NetSuite) — uses · Software
- [AWS S3](/Products/AWS_S3) — uses · Products
- [Google Cloud Storage](/Products/Google_Cloud_Storage) — uses · Products

### Optimizes

- [Straight-Through Processing Rate](/Metrics/Straight-Through_Processing_Rate) — optimizes · Metrics
- [Document Processing Latency](/Metrics/Document_Processing_Latency) — optimizes · Metrics
- [Exception Resolution Time](/Metrics/Exception_Resolution_Time) — optimizes · Metrics
- [Field Extraction Accuracy](/Metrics/Field_Extraction_Accuracy) — optimizes · Metrics

### Who consumes this

- [Accounts Payable Agent](/Agents/Accounts_Payable_Agent) — consumed by · Agents
- [Commercial Underwriting Agent](/Agents/Commercial_Underwriting_Agent) — consumed by · Agents
- [Logistics Triage Agent](/Agents/Logistics_Triage_Agent) — consumed by · Agents

### Similar Agents

- [Receipt Extraction API](/Agents/Receipt_Extraction_API) — similar · Agents
- [Agnostic Ingestion API](/Agents/Agnostic_Ingestion_API) — similar · Agents
- [Unstructured Payroll API](/Agents/Unstructured_Payroll_API) — similar · Agents

### Similar Software

- [Semantic Data Parser](/Software/Semantic_Data_Parser) — similar · Software
- [Invoice Extraction Engine](/Agents/Accounts_Payable_Clerk/Software/Invoice_Extraction_Engine) — similar · Software
- [Contract Intelligence API](/Software/Contract_Intelligence_API) — similar · Software
- [Contract Clause Extraction API](/Software/Contract_Clause_Extraction_API) — similar · Software
- [PDF Vector Extraction API](/Software/PDF_Vector_Extraction_API) — similar · Software

### Similar Startups

- [Napot](/Startups/Napot) — similar · Startups
- [Parseaxis](/Startups/Parseaxis) — similar · Startups
- [Accocument](/Startups/Accocument) — similar · Startups
- [Paperinsight](/Startups/Paperinsight) — similar · Startups
- [Quintorg](/CompanyTypes/Accounting_Firm/Problems/Standardize_Unstructured_Tax_Documents/Startups/Quintorg) — similar · Startups
- [Foliumquay](/Startups/Foliumquay) — similar · Startups
- [Contextual Clerk](/Startups/Contextual_Clerk) — similar · Startups
- [Bridgack](/Startups/Bridgack) — similar · Startups
- [Sievezone](/Problems/Document_Layout_Extraction/Startups/Sievezone) — similar · Startups
- [Acuity Extract](/Startups/Acuity_Extract) — similar · Startups
- [Concalent](/Startups/Concalent) — similar · Startups
- [Docapacity](/Startups/Docapacity) — similar · Startups
