{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/withverifa-com/json-schema/withverifa-com-document-detail-schema.json",
  "title": "DocumentDetail",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/withverifa-com-openapi.yml#/components/schemas/DocumentDetail",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Document ID (`doc_*`)."
    },
    "org_id": {
      "type": "string",
      "description": "Organization ID."
    },
    "session_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Associated session ID, if any."
    },
    "identity_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Associated identity ID, if any."
    },
    "document_type": {
      "$ref": "#/$defs/DocumentDetailDocumentType"
    },
    "classification": {
      "type": [
        "string",
        "null"
      ],
      "description": "Detected or assigned document classification (e.g. passport, drivers_license)."
    },
    "status": {
      "$ref": "#/$defs/DocumentDetailStatus"
    },
    "mime_type": {
      "type": [
        "string",
        "null"
      ],
      "description": "MIME type of the uploaded file."
    },
    "file_size_bytes": {
      "type": [
        "integer",
        "null"
      ],
      "description": "File size in bytes."
    },
    "original_filename": {
      "type": [
        "string",
        "null"
      ],
      "description": "Original filename at upload time."
    },
    "page_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Number of pages (for multi-page documents)."
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {
        "description": "Any type"
      },
      "description": "Arbitrary key-value metadata."
    },
    "upload_source": {
      "type": [
        "string",
        "null"
      ],
      "description": "How the document was uploaded (api, capture, dashboard)."
    },
    "download_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "HMAC-signed download URL (when available)."
    },
    "preview_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "Server-side JPEG preview URL for page 1. Works for both PDFs (rendered via PyMuPDF) and images. Same HMAC signature as download_url. Null for redacted documents."
    },
    "extracted_fields": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "description": "Any type"
      },
      "description": "Structured field extraction produced by Verifa's document\nextractor. Populated when the document's matched\n`document_type` has non-empty `extraction_hints`. Each key is\none of the field names from the type's `extraction_hints`,\nand each value is either the extracted string or `null` if\nthe field was not visible in the document. `null` until the\nverification pipeline has run.\n"
    },
    "extracted_fields_confidence": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "number",
        "format": "double",
        "minimum": 0,
        "maximum": 1
      },
      "description": "Per-field token-presence confidence (0.0-1.0) for the\ncorresponding entries in `extracted_fields`. Computed by\nchecking whether each extracted value's tokens actually\nappear in the underlying OCR text. Values below ~0.5 are\nlikely hallucinations and should be flagged for reviewer\nattention. `null` until extraction has run.\n"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "document_type",
    "status",
    "created_at"
  ],
  "$defs": {
    "DocumentDetailDocumentType": {
      "type": "string",
      "enum": [
        "id_front",
        "id_back",
        "selfie",
        "proof_of_address",
        "other"
      ],
      "title": "DocumentDetailDocumentType"
    },
    "DocumentDetailStatus": {
      "type": "string",
      "enum": [
        "pending",
        "processing",
        "completed",
        "failed",
        "redacted"
      ],
      "title": "DocumentDetailStatus"
    }
  }
}