{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/invoicedataextraction-com/json-schema/invoicedataextraction-com-extraction-results-response-schema.json",
  "title": "ExtractionResultsResponse",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/invoicedataextraction-com-openapi.json#/components/schemas/ExtractionResultsResponse",
  "type": "object",
  "required": [
    "success",
    "extraction_id",
    "status",
    "output_structure",
    "output_expires_at",
    "json_typed_values",
    "columns",
    "rows",
    "offset",
    "limit",
    "row_count",
    "total_rows",
    "has_more",
    "next_offset",
    "review_needed",
    "pages"
  ],
  "properties": {
    "success": {
      "type": "boolean",
      "const": true
    },
    "extraction_id": {
      "type": "string",
      "format": "uuid"
    },
    "status": {
      "type": "string",
      "const": "completed"
    },
    "output_structure": {
      "type": "string",
      "enum": [
        "per_invoice",
        "per_line_item"
      ]
    },
    "output_expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "json_typed_values": {
      "type": "boolean",
      "description": "`true` when values carry native JSON types; `false` when every value is a string."
    },
    "columns": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The output column names in order."
    },
    "rows": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      },
      "description": "One object per row with a value under every column. Row `i` of the page (from 0) is data row `offset + i + 1`."
    },
    "offset": {
      "type": "integer"
    },
    "limit": {
      "type": "integer"
    },
    "row_count": {
      "type": "integer"
    },
    "total_rows": {
      "type": "integer"
    },
    "has_more": {
      "type": "boolean"
    },
    "next_offset": {
      "type": [
        "integer",
        "null"
      ]
    },
    "review_needed": {
      "$ref": "#/$defs/ReviewNeeded"
    },
    "pages": {
      "$ref": "#/$defs/Pages"
    }
  },
  "$defs": {
    "PageFailureReason": {
      "type": "object",
      "required": [
        "code",
        "message",
        "affected_pages"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "affected_pages": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "file_name",
              "pages"
            ],
            "properties": {
              "file_name": {
                "type": "string"
              },
              "pages": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "PageReference": {
      "type": "object",
      "required": [
        "file_name",
        "page"
      ],
      "properties": {
        "file_name": {
          "type": "string"
        },
        "page": {
          "type": "integer"
        }
      }
    },
    "Pages": {
      "type": "object",
      "description": "Which pages were processed and which failed; data from failed pages is missing from the output.",
      "required": [
        "successful_count",
        "failed_count",
        "successful",
        "failed",
        "failure_reasons"
      ],
      "properties": {
        "successful_count": {
          "type": "integer"
        },
        "failed_count": {
          "type": "integer"
        },
        "successful": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PageReference"
          }
        },
        "failed": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PageReference"
          }
        },
        "failure_reasons": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PageFailureReason"
          }
        }
      }
    },
    "ReviewNeeded": {
      "type": "object",
      "description": "Rows that need a human's check before the data is relied on. Check `count` first.",
      "required": [
        "count",
        "items"
      ],
      "properties": {
        "count": {
          "type": "integer"
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ReviewNeededItem"
          }
        }
      }
    },
    "ReviewNeededItem": {
      "type": "object",
      "required": [
        "message",
        "affected_fields",
        "output_row_numbers",
        "source_references"
      ],
      "properties": {
        "message": {
          "type": "string"
        },
        "affected_fields": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Empty when the concern is about the row or document rather than particular fields."
        },
        "output_row_numbers": {
          "type": "array",
          "items": {
            "type": "integer"
          },
          "description": "1-based data row numbers, not counting the header row."
        },
        "source_references": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}