extraction

Extract Structured Data

Extract structured data from a file or URL using AI.

Upload a file (or provide a URL) along with a typed JSON schema describing the fields you want extracted. Each field must have a type and description. Returns structured data matching your schema with guaranteed type conformance.

Example schema:

{
  "invoice_number": {"type": "string", "description": "The invoice number"},
  "total_amount": {"type": "number", "description": "Total amount due", "required": true},
  "status": {"type": "string", "enum": ["paid", "unpaid", "overdue"]},
  "line_items": {
    "type": "array",
    "description": "Each line item",
    "items": {
      "type": "object",
      "properties": {
        "description": {"type": "string"},
        "quantity": {"type": "integer"},
        "unit_price": {"type": "number"}
      }
    }
  }
}

Supported types: string, number, integer, boolean, array, object

Supported formats: PDF, DOCX, XLSX, PPTX, CSV, images (JPG, PNG), and any file type supported by the markdown conversion endpoint.

Vision mode: For images or scanned documents, set use_vision=true for highest accuracy on visual content.

post/api/v1/extract

Request

  • Base URL: https://docs.thedrive.ai (the document declares no server; this is the origin it was published from)
  • URL: https://docs.thedrive.ai/api/v1/extract
  • Auth: none declared

Headers

X-API-Keystring

Response

Successful Response

successboolean

True if all required fields were found. False if any required field is missing (partial data still returned).

dataobject required

Extracted structured data matching the provided schema. Types are guaranteed when using typed schema.

confidenceobject

Per-field calibrated confidence scores (0.0–1.0). Composite of LLM self-report, token logprobs, and OCR quality weighted by extraction method.

citationsobject

Per-field source text snippets from the document

filenamestring required

Original filename or URL

content_typestring nullable

Detected MIME type

model_usedstring required

Model used for extraction (fast or accurate)

extraction_methodstring required

How text was extracted: text, ocr, ocr+vision, vision, or dom+text

text_lengthinteger required

Length of extracted text processed

pages_processedinteger

Number of document pages actually read (0 for non-paginated files)

total_pagesinteger

Total pages in the document (0 for non-paginated files)

credits_usedinteger

Credits consumed for this extraction

schema_format'typed'

Schema format used for extraction/analysis.

field_statusobject nullable

Per-field status (typed schemas only).

missing_requiredstring[] nullable

List of required fields that could not be found (typed schemas only). Present only when success=false.

quality_signalsobject nullable

Raw quality signals used for confidence calibration. 'ocr_quality': blended OCR quality (0.7mean + 0.3p10, 0–1, absent for non-OCR). 'doc_quality': geometric mean of LLM token probs (0–1). 'signal_disagreement': mean |llm_self_report - logprob| across fields. Values above 0.3 indicate the signals disagree — the model may be confidently wrong (high logprob, low self-report) or self-deprecating.

Example response

{
  "citations": {
    "invoice_number": "Invoice #: INV-2024-0042",
    "total_amount": "Total Due: $1,234.56"
  },
  "confidence": {
    "invoice_number": 0.96,
    "total_amount": 0.91,
    "vendor_name": 0.94
  },
  "content_type": "application/pdf",
  "credits_used": 7,
  "data": {
    "invoice_number": "INV-2024-0042",
    "total_amount": 1234.56,
    "vendor_name": "Acme Corp"
  },
  "extraction_method": "text",
  "field_status": {
    "invoice_number": {
      "confidence": 0.96,
      "required": false,
      "status": "found",
      "type": "string"
    },
    "total_amount": {
      "confidence": 0.91,
      "required": true,
      "status": "found",
      "type": "number"
    },
    "vendor_name": {
      "confidence": 0.94,
      "required": false,
      "status": "found",
      "type": "string"
    }
  },
  "filename": "invoice.pdf",
  "model_used": "fast",
  "pages_processed": 50,
  "schema_format": "typed",
  "success": true,
  "text_length": 2450,
  "total_pages": 1200
}

Changes

No recorded changes to this operation across all 1 revision of this API.