{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/webcite/json-schema/webcite-extract-response-dto-schema.json",
  "title": "ExtractResponseDto",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/webcite-openapi.json#/components/schemas/ExtractResponseDto",
  "properties": {
    "code": {
      "description": "The stable classification of `reason`, safe to switch on. Null on a complete read.\n\n| Code | What it means | What to do |\n|------|---------------|------------|\n| `source_too_large` | a size or expansion ceiling refused the read | `reason` carries the observed value and the limit; send a smaller file |\n| `source_encrypted` | the container is password-protected | send an unlocked copy |\n| `source_corrupt` | the container could not be opened as the format it declares | re-export the file |\n| `unsupported_format` | no reader is registered for this format | convert it |\n| `ocr_unavailable` | the page had no text layer and no vision provider is configured | configure a vision key, or send a text-layer file |\n| `partial_extraction` | some of the source was recovered and some was not | use what came back; `lost[]` names the rest |\n| `empty_source` | the source was read and held nothing | a fact about the file, not a failure — nothing to retry |\n| `extraction_error` | our failure | retry |",
      "enum": [
        "source_too_large",
        "source_encrypted",
        "source_corrupt",
        "unsupported_format",
        "ocr_unavailable",
        "partial_extraction",
        "empty_source",
        "extraction_error"
      ],
      "type": [
        "string",
        "null"
      ]
    },
    "complete": {
      "description": "Present, and only ever `false`, when the read did not recover the whole source. Absent on a complete read, so seeing it is a determination rather than a default.",
      "type": "boolean"
    },
    "credit_usage": {
      "allOf": [
        {
          "$ref": "#/$defs/CreditUsageDto"
        }
      ],
      "description": "The charge with a snapshot of the account balance. The same figures are sent as `X-Credits-*` response headers."
    },
    "extraction_method": {
      "description": "The path that produced most of this document's text.",
      "enum": [
        "text_layer",
        "ocr",
        "spreadsheet_cells",
        "none"
      ],
      "type": "string"
    },
    "format": {
      "description": "The format the bytes were read as.",
      "type": "string"
    },
    "lost": {
      "description": "The parts that were not recovered. Absent on a complete read.",
      "items": {
        "$ref": "#/$defs/LostPartDto"
      },
      "type": "array"
    },
    "markdown": {
      "description": "The whole document as markdown. Empty when nothing was read.",
      "type": "string"
    },
    "operation_id": {
      "description": "Identifier of this billed operation. Quote it when asking about a charge.",
      "type": [
        "string",
        "null"
      ]
    },
    "reason": {
      "description": "Free text naming the cause, straight from whatever refused or failed — `extraction_failed:File is password-protected`, `spreadsheet_too_large:bytes:33554433>33554432`. Carries detail no enum can (the observed value and the limit are both in it) and is NOT stable: it includes dependency error text. Display it; do not branch on it. Null on a complete read.",
      "type": [
        "string",
        "null"
      ]
    },
    "sheets": {
      "description": "Spreadsheets only: every sheet the workbook declares, in workbook order, with its structure and read state.",
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array"
    },
    "state": {
      "description": "How much of the source the read recovered, in one word.",
      "enum": [
        "complete",
        "partial",
        "unsupported",
        "error"
      ],
      "type": "string"
    },
    "units": {
      "description": "The document part by part, in source order: one unit per page or sheet. Empty when nothing was read.",
      "items": {
        "$ref": "#/$defs/ExtractUnitDto"
      },
      "type": "array"
    },
    "usage": {
      "allOf": [
        {
          "$ref": "#/$defs/ExtractUsageDto"
        }
      ],
      "description": "What this request was charged: the metered cost of its page reads, in credits to 4 decimal places. 0 when nothing readable came back or no page image was read."
    }
  },
  "required": [
    "format",
    "markdown",
    "extraction_method",
    "state",
    "reason",
    "code",
    "units",
    "operation_id",
    "usage"
  ],
  "type": "object",
  "$defs": {
    "CreditUsageDto": {
      "properties": {
        "credits_remaining": {
          "description": "Credits left in the current billing period after this request.",
          "type": [
            "number",
            "null"
          ]
        },
        "credits_used": {
          "description": "Credits this request deducted. Null when the charge was not recorded.",
          "type": [
            "number",
            "null"
          ]
        },
        "monthly_allocation": {
          "description": "Credits the plan grants each billing period.",
          "type": [
            "number",
            "null"
          ]
        },
        "operation_id": {
          "description": "The same identifier as the top-level `operation_id`.",
          "type": [
            "string",
            "null"
          ]
        },
        "overage_enabled": {
          "description": "Whether the account continues past its allocation on overage billing.",
          "type": [
            "boolean",
            "null"
          ]
        }
      },
      "required": [
        "credits_used",
        "credits_remaining",
        "monthly_allocation",
        "overage_enabled",
        "operation_id"
      ],
      "type": "object"
    },
    "ExtractElementDto": {
      "properties": {
        "bbox": {
          "description": "`[x0, y0, x1, y1]` as fractions of the page width and height, origin at the top left, `x0 < x1` and `y0 < y1`.",
          "items": {
            "type": "number"
          },
          "maxItems": 4,
          "minItems": 4,
          "type": "array"
        },
        "description": {
          "description": "Pictures only: what the picture shows, in the reader's words. Kept apart from `markdown`, which holds source text only.",
          "type": "string"
        },
        "markdown": {
          "description": "The block transcribed as Markdown. Tables are HTML or pipe tables; a picture carries its readable lettering and any chart data table. Can be empty for a picture that has only a `description`.",
          "type": "string"
        },
        "type": {
          "description": "What the block is. `page_header` and `page_footer` mark running headers and footers.",
          "enum": [
            "text",
            "title",
            "section_header",
            "table",
            "picture",
            "list_item",
            "list",
            "page_header",
            "page_footer",
            "caption",
            "footnote",
            "formula"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "markdown",
        "bbox"
      ],
      "type": "object"
    },
    "ExtractPageChargeDto": {
      "properties": {
        "credits": {
          "description": "Credits this page cost: the model cost of every read made for it, at list price, to 4 decimal places.",
          "type": "number"
        },
        "page": {
          "description": "1-based page number, the `index` of the unit it paid for.",
          "type": "number"
        },
        "page_type": {
          "description": "The kind of page the reader was chosen for, as in `units[].reader.page_type`.",
          "type": "string"
        }
      },
      "required": [
        "page",
        "credits"
      ],
      "type": "object"
    },
    "ExtractPageGeometryDto": {
      "properties": {
        "coordinateSystem": {
          "description": "The coordinate system of every `elements[].bbox` on this unit.",
          "enum": [
            "normalized-top-left-v1"
          ],
          "type": "string"
        },
        "height": {
          "description": "Page height in PDF points, or in pixels for an image.",
          "type": "number"
        },
        "rotation": {
          "description": "The page rotation in degrees that the boxes already account for.",
          "type": "number"
        },
        "width": {
          "description": "Page width in PDF points, or in pixels for an image.",
          "type": "number"
        }
      },
      "required": [
        "coordinateSystem",
        "width",
        "height",
        "rotation"
      ],
      "type": "object"
    },
    "ExtractPageReaderDto": {
      "properties": {
        "page_type": {
          "description": "What kind of page this was judged to be before it was read, from its text layer and drawing: `scan` (an image with little or no text layer), `form`, `dense` (a table with very many cells), `table`, `chart`, `complex_text` (several columns, rotated lines, non-Latin script or a damaged text layer) or `plain_text`.",
          "enum": [
            "scan",
            "form",
            "dense",
            "table",
            "chart",
            "complex_text",
            "plain_text"
          ],
          "type": "string"
        }
      },
      "required": [
        "page_type"
      ],
      "type": "object"
    },
    "ExtractUnitDto": {
      "properties": {
        "content_sha256": {
          "description": "SHA-256 of the unit content, when the reader recorded one.",
          "type": "string"
        },
        "elements": {
          "description": "The page as typed blocks in reading order, each with a box. Present on visually read pages, and on a text-layer page whose blocks could be placed from the text layer; absent otherwise.",
          "items": {
            "$ref": "#/$defs/ExtractElementDto"
          },
          "type": "array"
        },
        "extraction_method": {
          "description": "How this unit's text was produced. `ocr` means the page image was read.",
          "enum": [
            "text_layer",
            "ocr",
            "spreadsheet_cells",
            "none"
          ],
          "type": "string"
        },
        "geometry": {
          "allOf": [
            {
              "$ref": "#/$defs/ExtractPageGeometryDto"
            }
          ],
          "description": "Present with `elements`: the page size and the coordinate system of the boxes."
        },
        "image_input": {
          "description": "Present when a page with a text layer was read from its rendered image instead of the PDF, because the text layer does not carry the printed text: the checks that found it. `unmapped`: the layer holds control or private-use characters where the page prints letters. `garbled`: the layer's words have the shapes of a broken font map. `hidden` (lite mode only): the layer is drawn invisibly under a scan, an embedded OCR layer.",
          "items": {
            "enum": [
              "unmapped",
              "garbled",
              "hidden"
            ],
            "type": "string"
          },
          "type": "array"
        },
        "index": {
          "description": "1-based position of the part in the document.",
          "type": "number"
        },
        "kind": {
          "description": "The kind of part: `page` for PDFs and images, `sheet` for spreadsheets; other formats name their own parts (`slide`, `document`, `table`, `message_body`, ...).",
          "type": "string"
        },
        "mode": {
          "description": "Present on every unit of a `mode: \"lite\"` request; absent on a standard request.",
          "enum": [
            "lite"
          ],
          "type": "string"
        },
        "provenance": {
          "allOf": [
            {
              "$ref": "#/$defs/ExtractUnitProvenanceDto"
            }
          ],
          "description": "Where in the source this unit came from."
        },
        "reader": {
          "allOf": [
            {
              "$ref": "#/$defs/ExtractPageReaderDto"
            }
          ],
          "description": "Visually read pages only, when the server routes pages by type: the kind of page it was read as."
        },
        "reason": {
          "description": "Present with `state`: free text naming what went wrong on this unit. Display it; do not branch on it.",
          "type": "string"
        },
        "sheet": {
          "additionalProperties": true,
          "description": "Sheet units only: the tab's native structure (`name`, `visibility`, `merges`, and `cells` when the workbook was parsed for this request).",
          "type": "object"
        },
        "state": {
          "description": "Present only when this unit was not read completely. The same unit is named in `lost[]`.",
          "enum": [
            "partial",
            "unreadable",
            "error"
          ],
          "type": "string"
        },
        "text": {
          "description": "The part as Markdown (CSV for a sheet). On a page with `elements` it is the same reading as the elements in order.",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "index",
        "text",
        "provenance",
        "extraction_method"
      ],
      "type": "object"
    },
    "ExtractUnitProvenanceDto": {
      "properties": {
        "endMs": {
          "description": "End offset in milliseconds (media).",
          "type": "number"
        },
        "messageId": {
          "description": "Message identifier (email).",
          "type": "string"
        },
        "page": {
          "description": "1-based page number (PDFs and images).",
          "type": "number"
        },
        "part": {
          "description": "Message part (email).",
          "type": "string"
        },
        "path": {
          "description": "Location inside the container (structured documents).",
          "type": "string"
        },
        "range": {
          "description": "Cell range the unit covers (spreadsheets).",
          "type": "string"
        },
        "sheet": {
          "description": "Workbook tab name (spreadsheets).",
          "type": "string"
        },
        "slide": {
          "description": "1-based slide number (presentations).",
          "type": "number"
        },
        "startMs": {
          "description": "Start offset in milliseconds (media).",
          "type": "number"
        },
        "track": {
          "description": "Track name (media).",
          "type": "string"
        }
      },
      "type": "object"
    },
    "ExtractUsageDto": {
      "properties": {
        "credits": {
          "description": "Credits actually deducted; null when a priced operation was not metered. Zero denotes a genuinely free operation.",
          "type": [
            "number",
            "null"
          ]
        },
        "page_charges": {
          "description": "One line for each page charged. The lines add up to `credits` to within rounding; when the charge stopped at the balance, `credits` is lower than their sum.",
          "items": {
            "$ref": "#/$defs/ExtractPageChargeDto"
          },
          "type": "array"
        },
        "pages": {
          "description": "Pages this request was charged for: the PDF pages and images that came back with text. A page that could not be read is not counted. 0 for a spreadsheet or a text document, which no model reads.",
          "type": "number"
        }
      },
      "required": [
        "credits"
      ],
      "type": "object"
    },
    "LostPartDto": {
      "properties": {
        "code": {
          "description": "The stable classification of this part's `reason`. Same vocabulary as the document-level `code`; the two can differ, because a document that recovered most of itself is `partial_extraction` while the one part it lost names its own cause.",
          "enum": [
            "source_too_large",
            "source_encrypted",
            "source_corrupt",
            "unsupported_format",
            "ocr_unavailable",
            "partial_extraction",
            "empty_source",
            "extraction_error"
          ],
          "type": [
            "string",
            "null"
          ]
        },
        "index": {
          "description": "1-based page / sheet index, as on the unit that failed.",
          "type": "number"
        },
        "kind": {
          "description": "Which kind of unit was lost.",
          "enum": [
            "page",
            "sheet"
          ],
          "type": "string"
        },
        "reason": {
          "description": "Free text: what the reader said about this part.",
          "type": [
            "string",
            "null"
          ]
        },
        "sheet": {
          "description": "Sheet units only: the tab the workbook declared.",
          "type": "string"
        },
        "state": {
          "description": "What happened to this part specifically.",
          "enum": [
            "partial",
            "unreadable",
            "error"
          ],
          "type": "string"
        }
      },
      "required": [
        "kind",
        "index",
        "state",
        "reason",
        "code"
      ],
      "type": "object"
    }
  }
}