{
  "openapi": "3.0.3",
  "info": {
    "title": "Docuoria",
    "description": "Deterministic PDF data extraction: the Docuoria cloud host's REST routes, one per catalogue tool, and the upload and download routes. Authenticate with a connection key as a bearer token, or with OAuth. Every error is application/problem+json.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.docuoria.com"
    }
  ],
  "paths": {
    "/account": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Account",
        "description": "Reports the organisation, the caller's role, each purchase and seat's allowance, used, and remaining, and the billing link.",
        "operationId": "account",
        "responses": {
          "200": {
            "description": "The account result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "account"
      }
    },
    "/batch": {
      "post": {
        "tags": [
          "Extraction"
        ],
        "summary": "Batch extract",
        "description": "Runs extract over several documents as queued work, writing each entry as it completes, and returns a job id to poll with job_status.",
        "operationId": "batchExtract",
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "documents"
                ],
                "type": "object",
                "properties": {
                  "documents": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The documents, as a JSON array of strings (a comma-separated list also works): their ids on the cloud host, their paths on the local host."
                  },
                  "format": {
                    "enum": [
                      "csv",
                      "json"
                    ],
                    "type": "string",
                    "description": "The output format, csv or json; omitted is csv."
                  },
                  "ledger": {
                    "type": "string",
                    "description": "The account ledger id to append each result to."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The batch_extract result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "batch_extract"
      }
    },
    "/classify": {
      "post": {
        "tags": [
          "Extraction"
        ],
        "summary": "Classify",
        "description": "Classifies a document against the account's templates and returns the ranked matches with a recommendation.",
        "operationId": "classify",
        "parameters": [
          {
            "name": "Content-Disposition",
            "in": "header",
            "description": "With an application/pdf body: the document's name, as attachment; filename=\"<name>.pdf\".",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The tool's arguments as a JSON object, with document an uploaded document's id; or the PDF itself.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "document"
                ],
                "type": "object",
                "properties": {
                  "document": {
                    "type": "string",
                    "description": "The document: its id on the cloud host, its path on the local host."
                  }
                }
              }
            },
            "application/pdf": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The classify result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClassifyContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "413": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "classify"
      }
    },
    "/documents": {
      "get": {
        "tags": [
          "Handoff"
        ],
        "summary": "List documents",
        "description": "Lists the documents the calling principal has uploaded.",
        "operationId": "listDocuments",
        "responses": {
          "200": {
            "description": "The list_documents result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentListContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "list_documents"
      },
      "post": {
        "tags": [
          "Handoff"
        ],
        "summary": "Upload document",
        "description": "Uploads one PDF to the caller's account and returns its receipt; the documentId is the document argument of every tool.",
        "operationId": "uploadDocument",
        "parameters": [
          {
            "name": "Content-Disposition",
            "in": "header",
            "description": "The document's name, as attachment; filename=\"<name>.pdf\".",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The PDF.",
          "content": {
            "application/pdf": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The upload's receipt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "413": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/documents/{id}": {
      "delete": {
        "tags": [
          "Handoff"
        ],
        "summary": "Delete document",
        "description": "Deletes an uploaded document by id.",
        "operationId": "deleteDocument",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The document's id.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The delete_document result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeletedContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "delete_document"
      }
    },
    "/downloads/{id}": {
      "get": {
        "tags": [
          "Extraction"
        ],
        "summary": "Download",
        "description": "Serves a result stored above the inline cap, once, within ten minutes of the call that returned its downloadId. The id is the credential.",
        "operationId": "download",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The downloadId a result carried.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The stored result, with the content type it was stored with.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Any JSON value."
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "security": []
      }
    },
    "/dry-run": {
      "post": {
        "tags": [
          "Authoring"
        ],
        "summary": "Dry run",
        "description": "Runs a template against a document without saving anything and returns the projected rows and completeness, with mapping diagnostics on request or when the result is incomplete.",
        "operationId": "dryRun",
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "document",
                  "template"
                ],
                "type": "object",
                "properties": {
                  "document": {
                    "type": "string",
                    "description": "The document: its id on the cloud host, its path on the local host."
                  },
                  "template": {
                    "type": "string",
                    "description": "Template JSON, a draft handle, or a stored template id."
                  },
                  "diagnostics": {
                    "type": "boolean",
                    "description": "Return per-mapping match traces even when the result is complete."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The dry_run result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DryRunContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "dry_run"
      }
    },
    "/evaluate-match": {
      "post": {
        "tags": [
          "Authoring"
        ],
        "summary": "Evaluate match",
        "description": "Scores a document against a template's match rule and returns the score breakdown, the requirements met, and ambiguity evidence when the match is close.",
        "operationId": "evaluateMatch",
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "document",
                  "template"
                ],
                "type": "object",
                "properties": {
                  "document": {
                    "type": "string",
                    "description": "The document: its id on the cloud host, its path on the local host."
                  },
                  "template": {
                    "type": "string",
                    "description": "Template JSON, a draft handle, or a stored template id."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The evaluate_match result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EvaluateMatchContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "evaluate_match"
      }
    },
    "/extract": {
      "post": {
        "tags": [
          "Extraction"
        ],
        "summary": "Extract",
        "description": "Extracts structured data from a document: classifies it against the account's templates when no template is given, executes on a strong match, and returns the ranked classification and page map on a partial or no match.",
        "operationId": "extract",
        "parameters": [
          {
            "name": "template",
            "in": "query",
            "description": "With an application/pdf body: template JSON, a draft handle, or a stored template id; when omitted the document is classified first.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "description": "With an application/pdf body: the output format, csv or json; omitted is csv.",
            "schema": {
              "enum": [
                "csv",
                "json"
              ],
              "type": "string"
            }
          },
          {
            "name": "ledger",
            "in": "query",
            "description": "With an application/pdf body: the account ledger id to append the result to.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Content-Disposition",
            "in": "header",
            "description": "With an application/pdf body: the document's name, as attachment; filename=\"<name>.pdf\".",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The tool's arguments as a JSON object, with document an uploaded document's id; or the PDF itself.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "document"
                ],
                "type": "object",
                "properties": {
                  "document": {
                    "type": "string",
                    "description": "The document: its id on the cloud host, its path on the local host."
                  },
                  "template": {
                    "type": "string",
                    "description": "Template JSON, a draft handle, or a stored template id; when omitted the document is classified first."
                  },
                  "format": {
                    "enum": [
                      "csv",
                      "json"
                    ],
                    "type": "string",
                    "description": "The output format, csv or json; omitted is csv."
                  },
                  "ledger": {
                    "type": "string",
                    "description": "The account ledger id to append the result to."
                  }
                }
              }
            },
            "application/pdf": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The extract result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "413": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "extract"
      }
    },
    "/inspect": {
      "post": {
        "tags": [
          "Authoring"
        ],
        "summary": "Inspect",
        "description": "Returns a document's page map, with every page's text, blocks, and tables when the whole fits in one result; or the text, blocks, and tables for the requested pages.",
        "operationId": "inspect",
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "document"
                ],
                "type": "object",
                "properties": {
                  "document": {
                    "type": "string",
                    "description": "The document: its id on the cloud host, its path on the local host."
                  },
                  "pages": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "description": "The 1-based page numbers to return full detail for, as a JSON array such as [1, 2] (a comma-separated list also works); omitted returns only the page map."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The inspect result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InspectContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "inspect"
      }
    },
    "/jobs/{job}": {
      "get": {
        "tags": [
          "Extraction"
        ],
        "summary": "Job status",
        "description": "Reports a batch job's completed entries, documents not yet processed, and a summary once it is done.",
        "operationId": "jobStatus",
        "parameters": [
          {
            "name": "job",
            "in": "path",
            "description": "The batch job's id.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The job_status result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "job_status"
      }
    },
    "/ledgers": {
      "get": {
        "tags": [
          "Ledgers"
        ],
        "summary": "List ledgers",
        "description": "Lists the account's ledgers with their id, format, row count, and sources.",
        "operationId": "listLedgers",
        "responses": {
          "200": {
            "description": "The list_ledgers result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LedgerListContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "list_ledgers"
      }
    },
    "/ledgers/{ledger}": {
      "get": {
        "tags": [
          "Ledgers"
        ],
        "summary": "Read ledger",
        "description": "Returns a ledger's rows up to the result cap, or a download link above it.",
        "operationId": "readLedger",
        "parameters": [
          {
            "name": "ledger",
            "in": "path",
            "description": "The ledger's id.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The read_ledger result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LedgerContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "read_ledger"
      },
      "delete": {
        "tags": [
          "Ledgers"
        ],
        "summary": "Delete ledger",
        "description": "Deletes an account ledger and its rows by id; the documents the rows came from are not touched.",
        "operationId": "deleteLedger",
        "parameters": [
          {
            "name": "ledger",
            "in": "path",
            "description": "The ledger's id.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The delete_ledger result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeletedContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "delete_ledger"
      }
    },
    "/ledgers/{ledger}/entries": {
      "post": {
        "tags": [
          "Ledgers"
        ],
        "summary": "Append ledger rows",
        "description": "Appends rows extracted on the local host to an account ledger, recording each source once.",
        "operationId": "appendLedgerRows",
        "parameters": [
          {
            "name": "ledger",
            "in": "path",
            "description": "The ledger's id; created on first append.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "rows",
                  "source"
                ],
                "type": "object",
                "properties": {
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    },
                    "description": "The rows to append: a JSON array of objects."
                  },
                  "source": {
                    "type": "string",
                    "description": "The document's name; the ledger records each source once."
                  },
                  "template": {
                    "type": "string",
                    "description": "The id of the template that produced the rows; omitted records manual."
                  },
                  "format": {
                    "enum": [
                      "csv",
                      "json"
                    ],
                    "type": "string",
                    "description": "The ledger's format, csv or json; omitted uses the ledger's existing format, else json when rows is one JSON object, else csv."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The append_ledger_rows result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LedgerActionContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "append_ledger_rows"
      }
    },
    "/reference": {
      "get": {
        "tags": [
          "Guidance"
        ],
        "summary": "Reference",
        "description": "Returns the authoring card by default, or the full specification section for a topic.",
        "operationId": "reference",
        "parameters": [
          {
            "name": "topic",
            "in": "query",
            "description": "The specification topic; omitted returns the authoring card.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The reference result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReferenceContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "reference"
      }
    },
    "/regression-check": {
      "post": {
        "tags": [
          "Authoring"
        ],
        "summary": "Regression check",
        "description": "Compares a candidate template against the current one over a set of documents and passes only when no row is lost and no value changes.",
        "operationId": "regressionCheck",
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "template",
                  "candidate",
                  "documents"
                ],
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string",
                    "description": "The stored template's id: the template the candidate would replace."
                  },
                  "candidate": {
                    "type": "string",
                    "description": "The candidate template to compare: JSON, a draft handle, or a stored template id."
                  },
                  "documents": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The documents, as a JSON array of strings (a comma-separated list also works): their ids on the cloud host, their paths on the local host."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The regression_check result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RegressionContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "regression_check"
      }
    },
    "/survey": {
      "post": {
        "tags": [
          "Authoring"
        ],
        "summary": "Survey",
        "description": "Groups a set of documents into structural families, each with a representative, and lists the documents that matched no family.",
        "operationId": "survey",
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "documents"
                ],
                "type": "object",
                "properties": {
                  "documents": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The documents, as a JSON array of strings (a comma-separated list also works): their ids on the cloud host, their paths on the local host."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The survey result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SurveyContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "survey"
      }
    },
    "/templates": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "List templates",
        "description": "Lists the account's saved template ids.",
        "operationId": "listTemplates",
        "responses": {
          "200": {
            "description": "The list_templates result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateListContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "list_templates"
      },
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Save template",
        "description": "Saves a template to the account store, refusing an existing id unless replace is set.",
        "operationId": "saveTemplate",
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "template"
                ],
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string",
                    "description": "Template JSON, or a draft handle to promote."
                  },
                  "replace": {
                    "type": "boolean",
                    "description": "Replace an existing template of the same id; unrecoverable, and only after a passing regression_check."
                  },
                  "document": {
                    "type": "string",
                    "description": "A sample document of the template's type; when given, every pattern is proven under the match timeout before saving. The document: its id on the cloud host, its path on the local host."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The save_template result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaveTemplateContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "409": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "save_template"
      }
    },
    "/templates/{template}": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "Load template",
        "description": "Loads a saved template's JSON by id.",
        "operationId": "loadTemplate",
        "parameters": [
          {
            "name": "template",
            "in": "path",
            "description": "The stored template's id.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The load_template result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "load_template"
      },
      "put": {
        "tags": [
          "Templates"
        ],
        "summary": "Replace template",
        "description": "Replaces the stored template the path names with the inline template JSON in the body, whose identifier must equal the path's id. A replace cannot be undone: run regression_check first and replace only when it passes.",
        "operationId": "replaceTemplate",
        "parameters": [
          {
            "name": "template",
            "in": "path",
            "description": "The stored template's id; the body's template identifier must equal it.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The tool's arguments as a JSON object, with template the inline template JSON.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "template"
                ],
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string",
                    "description": "Template JSON, or a draft handle to promote."
                  },
                  "document": {
                    "type": "string",
                    "description": "A sample document of the template's type; when given, every pattern is proven under the match timeout before saving. The document: its id on the cloud host, its path on the local host."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The save_template result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaveTemplateContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "409": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "delete": {
        "tags": [
          "Templates"
        ],
        "summary": "Delete template",
        "description": "Deletes a saved template by id.",
        "operationId": "deleteTemplate",
        "parameters": [
          {
            "name": "template",
            "in": "path",
            "description": "The stored template's id.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The delete_template result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeletedContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "delete_template"
      }
    },
    "/test-patterns": {
      "post": {
        "tags": [
          "Authoring"
        ],
        "summary": "Test patterns",
        "description": "Tests one or more regular expressions against a document page and returns, per pattern, the matches with groups and gaps, or the near miss and each group alone on zero matches.",
        "operationId": "testPatterns",
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "document",
                  "patterns"
                ],
                "type": "object",
                "properties": {
                  "document": {
                    "type": "string",
                    "description": "The document: its id on the cloud host, its path on the local host."
                  },
                  "patterns": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The regular expressions to test, as a JSON array of strings such as [\"Invoice No\", \"Total\"]; a single pattern may be sent alone. A value that starts with [ and ends with ] must parse as the array."
                  },
                  "page": {
                    "type": "integer",
                    "description": "The 1-based page to test against; omitted tests the whole document.",
                    "format": "int32"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The test_patterns result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestPatternsContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "test_patterns"
      }
    },
    "/uploads": {
      "post": {
        "tags": [
          "Handoff"
        ],
        "summary": "Create upload",
        "description": "Opens a ticket authorizing the calling AI's code execution sandbox to upload PDFs to the caller's account for ten minutes.",
        "operationId": "createUpload",
        "responses": {
          "200": {
            "description": "The create_upload result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "create_upload"
      }
    },
    "/uploads/{ticket}": {
      "put": {
        "tags": [
          "Handoff"
        ],
        "summary": "Upload to ticket",
        "description": "Uploads one PDF on an upload ticket from create_upload and returns its receipt. Authenticate with the ticket's token as Authorization: Bearer <token>, not with the account's credential.",
        "operationId": "uploadToTicket",
        "parameters": [
          {
            "name": "ticket",
            "in": "path",
            "description": "The ticket's id, from create_upload.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Content-Disposition",
            "in": "header",
            "description": "The document's name, as attachment; filename=\"<name>.pdf\".",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The PDF.",
          "content": {
            "application/pdf": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The upload's receipt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "410": {
            "$ref": "#/components/responses/Problem"
          },
          "413": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "security": []
      },
      "delete": {
        "tags": [
          "Handoff"
        ],
        "summary": "Close upload ticket",
        "description": "Closes an upload ticket from create_upload. Authenticate with the ticket's token as Authorization: Bearer <token>, not with the account's credential.",
        "operationId": "closeUploadTicket",
        "parameters": [
          {
            "name": "ticket",
            "in": "path",
            "description": "The ticket's id, from create_upload.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The closed ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TicketClosedContract"
                }
              }
            }
          },
          "410": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "security": []
      }
    },
    "/validate-template": {
      "post": {
        "tags": [
          "Authoring"
        ],
        "summary": "Validate template",
        "description": "Validates a template's structure and returns errors with valid values; with no errors, a draft handle; with a document, proves every pattern under the match timeout.",
        "operationId": "validateTemplate",
        "requestBody": {
          "description": "The tool's arguments as a JSON object.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "template"
                ],
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string",
                    "description": "Template JSON, a draft handle, or a stored template id."
                  },
                  "document": {
                    "type": "string",
                    "description": "The document: its id on the cloud host, its path on the local host."
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The validate_template result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateContract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "402": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "x-docuoria-tool": "validate_template"
      }
    }
  },
  "components": {
    "schemas": {
      "AccountActionContract": {
        "required": [
          "name",
          "method",
          "path"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "method": {
            "type": "string"
          },
          "path": {
            "type": "string"
          }
        }
      },
      "AccountContract": {
        "required": [
          "organisationId",
          "role",
          "purchases",
          "seats",
          "billingLink",
          "addSeats",
          "readOnly",
          "next",
          "members",
          "connections",
          "actions",
          "organisationName",
          "readOnlyUntilUtc"
        ],
        "type": "object",
        "properties": {
          "organisationId": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "purchases": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PurchaseContract"
            }
          },
          "seats": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SeatContract"
            }
          },
          "billingLink": {
            "type": "string",
            "nullable": true
          },
          "addSeats": {
            "type": "string",
            "nullable": true
          },
          "readOnly": {
            "type": "boolean"
          },
          "next": {
            "type": "string"
          },
          "members": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MemberContract"
            },
            "nullable": true
          },
          "connections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConnectionContract"
            },
            "nullable": true
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountActionContract"
            },
            "nullable": true
          },
          "organisationName": {
            "type": "string",
            "nullable": true
          },
          "readOnlyUntilUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "AmbiguityEvidence": {
        "required": [
          "rootRuleChildren",
          "extractionMappings",
          "discriminatorTokensAbsent",
          "requirements"
        ],
        "type": "object",
        "properties": {
          "rootRuleChildren": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RuleChildOutcome"
            }
          },
          "extractionMappings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MappingOutcome"
            }
          },
          "discriminatorTokensAbsent": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requirements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UnsatisfiedRequirement"
            }
          }
        }
      },
      "AuthoringAllowanceContract": {
        "required": [
          "allowance",
          "used",
          "remaining"
        ],
        "type": "object",
        "properties": {
          "allowance": {
            "type": "integer",
            "format": "int64"
          },
          "used": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "remaining": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          }
        }
      },
      "BatchContract": {
        "required": [
          "jobId",
          "status",
          "completed",
          "notProcessed",
          "stoppedBy",
          "next"
        ],
        "type": "object",
        "properties": {
          "jobId": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "completed": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BatchEntryContract"
            }
          },
          "notProcessed": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "stoppedBy": {
            "type": "string",
            "nullable": true
          },
          "next": {
            "type": "string"
          }
        }
      },
      "BatchEntryContract": {
        "required": [
          "source",
          "status",
          "templateId",
          "completeness",
          "ledgerAction",
          "errorCode",
          "errorMessage"
        ],
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "templateId": {
            "type": "string",
            "nullable": true
          },
          "completeness": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CompletenessContract"
              }
            ],
            "nullable": true
          },
          "ledgerAction": {
            "type": "string",
            "nullable": true
          },
          "errorCode": {
            "type": "string",
            "nullable": true
          },
          "errorMessage": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "ClassificationContract": {
        "required": [
          "templateId",
          "recommendation",
          "score",
          "requirementsSatisfied",
          "specificity",
          "matchQuantity",
          "coverage",
          "ruleConfidence",
          "ambiguity"
        ],
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string"
          },
          "recommendation": {
            "type": "string"
          },
          "score": {
            "type": "number",
            "format": "double"
          },
          "requirementsSatisfied": {
            "type": "boolean"
          },
          "specificity": {
            "type": "number",
            "format": "double"
          },
          "matchQuantity": {
            "type": "number",
            "format": "double"
          },
          "coverage": {
            "type": "number",
            "format": "double"
          },
          "ruleConfidence": {
            "type": "number",
            "format": "double"
          },
          "ambiguity": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AmbiguityEvidence"
              }
            ],
            "nullable": true
          }
        }
      },
      "ClassifyContract": {
        "required": [
          "matches",
          "recommendation",
          "next"
        ],
        "type": "object",
        "properties": {
          "matches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClassificationContract"
            }
          },
          "recommendation": {
            "type": "string"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "CompletenessContract": {
        "required": [
          "isComplete",
          "missingRequiredFields",
          "emptyDeclaredCollections",
          "unsatisfiedRequirements"
        ],
        "type": "object",
        "properties": {
          "isComplete": {
            "type": "boolean"
          },
          "missingRequiredFields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "emptyDeclaredCollections": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unsatisfiedRequirements": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ConnectionContract": {
        "required": [
          "id",
          "label",
          "createdUtc",
          "lastUsedUtc"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "createdUtc": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "DeletedContract": {
        "required": [
          "id",
          "deleted",
          "next"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "DocumentEntryContract": {
        "required": [
          "documentId",
          "name",
          "bytes",
          "sha256",
          "pageCount",
          "expiresUtc"
        ],
        "type": "object",
        "properties": {
          "documentId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "bytes": {
            "type": "integer",
            "format": "int64"
          },
          "sha256": {
            "type": "string"
          },
          "pageCount": {
            "type": "integer",
            "format": "int32"
          },
          "expiresUtc": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DocumentListContract": {
        "required": [
          "documents",
          "next"
        ],
        "type": "object",
        "properties": {
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentEntryContract"
            }
          },
          "next": {
            "type": "string"
          }
        }
      },
      "DocumentMetadata": {
        "required": [
          "title",
          "author",
          "subject",
          "keywords",
          "creator",
          "producer",
          "creationDate",
          "modificationDate"
        ],
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "nullable": true
          },
          "author": {
            "type": "string",
            "nullable": true
          },
          "subject": {
            "type": "string",
            "nullable": true
          },
          "keywords": {
            "type": "string",
            "nullable": true
          },
          "creator": {
            "type": "string",
            "nullable": true
          },
          "producer": {
            "type": "string",
            "nullable": true
          },
          "creationDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "modificationDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "DryRunContract": {
        "required": [
          "kind",
          "projection",
          "completeness",
          "diagnostics",
          "fieldPath",
          "error",
          "next"
        ],
        "type": "object",
        "properties": {
          "kind": {
            "type": "string"
          },
          "projection": {
            "type": "object",
            "additionalProperties": {
              "description": "Any JSON value.",
              "nullable": true
            },
            "nullable": true
          },
          "completeness": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CompletenessContract"
              }
            ],
            "nullable": true
          },
          "diagnostics": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MappingTrace"
            },
            "nullable": true
          },
          "fieldPath": {
            "type": "string",
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          },
          "next": {
            "type": "string"
          }
        }
      },
      "EvaluateMatchContract": {
        "required": [
          "isMatch",
          "recommendation",
          "score",
          "requirements",
          "matchedRules",
          "ambiguity",
          "next"
        ],
        "type": "object",
        "properties": {
          "isMatch": {
            "type": "boolean"
          },
          "recommendation": {
            "type": "string"
          },
          "score": {
            "type": "number",
            "format": "double"
          },
          "requirements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RequirementResult"
            }
          },
          "matchedRules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MatchedRuleSummary"
            }
          },
          "ambiguity": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AmbiguityEvidence"
              }
            ],
            "nullable": true
          },
          "next": {
            "type": "string"
          }
        }
      },
      "ExtractContract": {
        "required": [
          "status",
          "templateId",
          "format",
          "contentType",
          "output",
          "downloadId",
          "downloadUrl",
          "completeness",
          "ranked",
          "pageMap",
          "ledger",
          "next",
          "ledgerError"
        ],
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "templateId": {
            "type": "string",
            "nullable": true
          },
          "format": {
            "type": "string",
            "nullable": true
          },
          "contentType": {
            "type": "string",
            "nullable": true
          },
          "output": {
            "type": "string",
            "nullable": true
          },
          "downloadId": {
            "type": "string",
            "nullable": true
          },
          "downloadUrl": {
            "type": "string",
            "nullable": true
          },
          "completeness": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CompletenessContract"
              }
            ],
            "nullable": true
          },
          "ranked": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClassificationContract"
            }
          },
          "pageMap": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PageMapContract"
            },
            "nullable": true
          },
          "ledger": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LedgerActionContract"
              }
            ],
            "nullable": true
          },
          "next": {
            "type": "string"
          },
          "ledgerError": {
            "allOf": [
              {
                "$ref": "#/components/schemas/OperationError"
              }
            ],
            "nullable": true
          }
        }
      },
      "GroupCapture": {
        "required": [
          "name",
          "index",
          "length",
          "value",
          "success"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "index": {
            "type": "integer",
            "format": "int32"
          },
          "length": {
            "type": "integer",
            "format": "int32"
          },
          "value": {
            "type": "string"
          },
          "success": {
            "type": "boolean"
          }
        }
      },
      "GroupTestRow": {
        "required": [
          "groupName",
          "subPattern",
          "matchesIndependently",
          "matchCount",
          "firstMatchText"
        ],
        "type": "object",
        "properties": {
          "groupName": {
            "type": "string"
          },
          "subPattern": {
            "type": "string"
          },
          "matchesIndependently": {
            "type": "boolean"
          },
          "matchCount": {
            "type": "integer",
            "format": "int32"
          },
          "firstMatchText": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "HaystackGap": {
        "required": [
          "start",
          "length",
          "text"
        ],
        "type": "object",
        "properties": {
          "start": {
            "type": "integer",
            "format": "int32"
          },
          "length": {
            "type": "integer",
            "format": "int32"
          },
          "text": {
            "type": "string"
          }
        }
      },
      "InspectContract": {
        "required": [
          "pageCount",
          "metadata",
          "pageMap",
          "pages",
          "next"
        ],
        "type": "object",
        "properties": {
          "pageCount": {
            "type": "integer",
            "format": "int32"
          },
          "metadata": {
            "$ref": "#/components/schemas/DocumentMetadata"
          },
          "pageMap": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PageMapContract"
            }
          },
          "pages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PageInspection"
            }
          },
          "next": {
            "type": "string"
          }
        }
      },
      "LedgerActionContract": {
        "required": [
          "ledgerId",
          "action",
          "rowsAdded",
          "totalRows",
          "totalSources",
          "columnsAdded",
          "next"
        ],
        "type": "object",
        "properties": {
          "ledgerId": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "rowsAdded": {
            "type": "integer",
            "format": "int32"
          },
          "totalRows": {
            "type": "integer",
            "format": "int32"
          },
          "totalSources": {
            "type": "integer",
            "format": "int32"
          },
          "columnsAdded": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "next": {
            "type": "string"
          }
        }
      },
      "LedgerContract": {
        "required": [
          "ledgerId",
          "format",
          "rowCount",
          "sources",
          "columns",
          "content",
          "downloadId",
          "downloadUrl",
          "next"
        ],
        "type": "object",
        "properties": {
          "ledgerId": {
            "type": "string"
          },
          "format": {
            "type": "string"
          },
          "rowCount": {
            "type": "integer",
            "format": "int32"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "downloadId": {
            "type": "string",
            "nullable": true
          },
          "downloadUrl": {
            "type": "string",
            "nullable": true
          },
          "next": {
            "type": "string"
          }
        }
      },
      "LedgerListContract": {
        "required": [
          "ledgers",
          "next"
        ],
        "type": "object",
        "properties": {
          "ledgers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LedgerContract"
            }
          },
          "next": {
            "type": "string"
          }
        }
      },
      "MappingOutcome": {
        "required": [
          "mappingName",
          "matchCount",
          "populatedFields"
        ],
        "type": "object",
        "properties": {
          "mappingName": {
            "type": "string"
          },
          "matchCount": {
            "type": "integer",
            "format": "int32"
          },
          "populatedFields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        }
      },
      "MappingTrace": {
        "required": [
          "fieldName",
          "matched",
          "matchedText",
          "matchIndex",
          "matchLength",
          "namedGroups",
          "sourceHaystack"
        ],
        "type": "object",
        "properties": {
          "fieldName": {
            "type": "string"
          },
          "matched": {
            "type": "boolean"
          },
          "matchedText": {
            "type": "string",
            "nullable": true
          },
          "matchIndex": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "matchLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "namedGroups": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "nullable": true
          },
          "sourceHaystack": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "MatchedRuleSummary": {
        "required": [
          "ruleType",
          "matched",
          "confidence",
          "detail"
        ],
        "type": "object",
        "properties": {
          "ruleType": {
            "type": "string"
          },
          "matched": {
            "type": "boolean"
          },
          "confidence": {
            "type": "number",
            "format": "double"
          },
          "detail": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "MemberContract": {
        "required": [
          "id",
          "userId",
          "email",
          "role",
          "state",
          "createdUtc"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "userId": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "createdUtc": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OperationError": {
        "required": [
          "code",
          "category",
          "message",
          "next"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "category": {
            "$ref": "#/components/schemas/OperationErrorCategory"
          },
          "message": {
            "type": "string"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "OperationErrorCategory": {
        "enum": [
          "licence-attention",
          "call-failed",
          "invalid-input",
          "incomplete",
          "not-found"
        ],
        "type": "string"
      },
      "PageInspection": {
        "required": [
          "pageNumber",
          "flattenedText",
          "blocks",
          "tables"
        ],
        "type": "object",
        "properties": {
          "pageNumber": {
            "type": "integer",
            "format": "int32"
          },
          "flattenedText": {
            "type": "string"
          },
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextBlock"
            }
          },
          "tables": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TableSnapshot"
            }
          }
        }
      },
      "PageMapContract": {
        "required": [
          "pageNumber",
          "textLength",
          "blockCount",
          "tables"
        ],
        "type": "object",
        "properties": {
          "pageNumber": {
            "type": "integer",
            "format": "int32"
          },
          "textLength": {
            "type": "integer",
            "format": "int32"
          },
          "blockCount": {
            "type": "integer",
            "format": "int32"
          },
          "tables": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TableShapeContract"
            }
          }
        }
      },
      "PatternMatch": {
        "required": [
          "index",
          "length",
          "value",
          "groups"
        ],
        "type": "object",
        "properties": {
          "index": {
            "type": "integer",
            "format": "int32"
          },
          "length": {
            "type": "integer",
            "format": "int32"
          },
          "value": {
            "type": "string"
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GroupCapture"
            }
          }
        }
      },
      "PatternNearMiss": {
        "required": [
          "partialMatch",
          "breakIndex"
        ],
        "type": "object",
        "properties": {
          "partialMatch": {
            "type": "string"
          },
          "breakIndex": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "PatternResultContract": {
        "required": [
          "pattern",
          "hasMatches",
          "matches",
          "gaps",
          "nearMiss",
          "groups",
          "error"
        ],
        "type": "object",
        "properties": {
          "pattern": {
            "type": "string"
          },
          "hasMatches": {
            "type": "boolean"
          },
          "matches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PatternMatch"
            }
          },
          "gaps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HaystackGap"
            }
          },
          "nearMiss": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PatternNearMiss"
              }
            ],
            "nullable": true
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GroupTestRow"
            },
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PdfBounds": {
        "required": [
          "x",
          "y",
          "width",
          "height"
        ],
        "type": "object",
        "properties": {
          "x": {
            "type": "number",
            "format": "double"
          },
          "y": {
            "type": "number",
            "format": "double"
          },
          "width": {
            "type": "number",
            "format": "double"
          },
          "height": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "Problem": {
        "required": [
          "type",
          "title",
          "status",
          "detail",
          "instance",
          "code",
          "category"
        ],
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "https://docuoria.com/problems/<code>",
            "format": "uri"
          },
          "title": {
            "type": "string",
            "description": "One sentence stating what went wrong."
          },
          "status": {
            "type": "integer",
            "description": "The HTTP status.",
            "format": "int32"
          },
          "detail": {
            "type": "string",
            "description": "The next step: what the caller does, and the one condition under which it asks the user."
          },
          "instance": {
            "type": "string",
            "description": "The request path."
          },
          "code": {
            "type": "string",
            "description": "The error code, for example rate-limit."
          },
          "category": {
            "$ref": "#/components/schemas/ProblemCategory"
          }
        },
        "description": "An RFC 9457 problem document."
      },
      "ProblemCategory": {
        "enum": [
          "licence-attention",
          "call-failed",
          "invalid-input",
          "incomplete",
          "not-found",
          "unauthenticated"
        ],
        "type": "string",
        "description": "The error's category: an operation's, or unauthenticated on the host's 401 for a request with no valid credential."
      },
      "PurchaseContract": {
        "required": [
          "id",
          "tier",
          "planState",
          "billingContact"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "tier": {
            "type": "string"
          },
          "planState": {
            "type": "string"
          },
          "billingContact": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "ReceiptContract": {
        "required": [
          "documentId",
          "name",
          "bytes",
          "sha256",
          "pageCount",
          "expiresUtc",
          "next"
        ],
        "type": "object",
        "properties": {
          "documentId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "bytes": {
            "type": "integer",
            "format": "int64"
          },
          "sha256": {
            "type": "string"
          },
          "pageCount": {
            "type": "integer",
            "format": "int32"
          },
          "expiresUtc": {
            "type": "string",
            "format": "date-time"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "ReferenceContract": {
        "required": [
          "topic",
          "text",
          "topics",
          "next"
        ],
        "type": "object",
        "properties": {
          "topic": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "topics": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "next": {
            "type": "string"
          }
        }
      },
      "RegressionContract": {
        "required": [
          "passed",
          "documents",
          "next"
        ],
        "type": "object",
        "properties": {
          "passed": {
            "type": "boolean"
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RegressionDocumentContract"
            }
          },
          "next": {
            "type": "string"
          }
        }
      },
      "RegressionDocumentContract": {
        "required": [
          "document",
          "passed",
          "differences"
        ],
        "type": "object",
        "properties": {
          "document": {
            "type": "string"
          },
          "passed": {
            "type": "boolean"
          },
          "differences": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "RequirementResult": {
        "required": [
          "kind",
          "satisfied",
          "detail"
        ],
        "type": "object",
        "properties": {
          "kind": {
            "type": "string"
          },
          "satisfied": {
            "type": "boolean"
          },
          "detail": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "RuleChildOutcome": {
        "required": [
          "ruleKind",
          "fired",
          "confidence",
          "tokensThatFired",
          "tokensThatDidNotFire"
        ],
        "type": "object",
        "properties": {
          "ruleKind": {
            "type": "string"
          },
          "fired": {
            "type": "boolean"
          },
          "confidence": {
            "type": "number",
            "format": "double"
          },
          "tokensThatFired": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "tokensThatDidNotFire": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        }
      },
      "SaveTemplateContract": {
        "required": [
          "templateId",
          "created",
          "replaced",
          "next"
        ],
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string"
          },
          "created": {
            "type": "boolean"
          },
          "replaced": {
            "type": "boolean"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "SeatContract": {
        "required": [
          "id",
          "label",
          "state",
          "allowance",
          "used",
          "remaining",
          "periodEndUtc",
          "authoring"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "allowance": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "used": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "remaining": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "periodEndUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "authoring": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AuthoringAllowanceContract"
              }
            ],
            "nullable": true
          }
        }
      },
      "SurveyContract": {
        "required": [
          "documentCount",
          "groups",
          "unmatched",
          "guidance",
          "next"
        ],
        "type": "object",
        "properties": {
          "documentCount": {
            "type": "integer",
            "format": "int32"
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyGroupContract"
            }
          },
          "unmatched": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyUnmatchedContract"
            }
          },
          "guidance": {
            "type": "string"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "SurveyGroupContract": {
        "required": [
          "templateId",
          "documents",
          "documentIds",
          "representative",
          "representativeId"
        ],
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string"
          },
          "documents": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "documentIds": {
            "type": "array",
            "items": {
              "type": "string",
              "nullable": true
            }
          },
          "representative": {
            "type": "string"
          },
          "representativeId": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "SurveyUnmatchedContract": {
        "required": [
          "document",
          "documentId",
          "pageCount",
          "structuralTokens"
        ],
        "type": "object",
        "properties": {
          "document": {
            "type": "string"
          },
          "documentId": {
            "type": "string",
            "nullable": true
          },
          "pageCount": {
            "type": "integer",
            "format": "int32"
          },
          "structuralTokens": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "TableShapeContract": {
        "required": [
          "totalRowCount",
          "headerPreview"
        ],
        "type": "object",
        "properties": {
          "totalRowCount": {
            "type": "integer",
            "format": "int32"
          },
          "headerPreview": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "TableSnapshot": {
        "required": [
          "headerPreview",
          "rowPreviews",
          "totalRowCount"
        ],
        "type": "object",
        "properties": {
          "headerPreview": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "rowPreviews": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "totalRowCount": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "TemplateContract": {
        "required": [
          "templateId",
          "json",
          "next"
        ],
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string"
          },
          "json": {
            "type": "string"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "TemplateListContract": {
        "required": [
          "templates",
          "count",
          "cap",
          "next"
        ],
        "type": "object",
        "properties": {
          "templates": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "count": {
            "type": "integer",
            "format": "int32"
          },
          "cap": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "next": {
            "type": "string"
          }
        }
      },
      "TemplateValidationError": {
        "required": [
          "code",
          "fieldPath",
          "message",
          "severity"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "fieldPath": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "severity": {
            "$ref": "#/components/schemas/ValidationSeverity"
          }
        }
      },
      "TestPatternsContract": {
        "required": [
          "results",
          "next"
        ],
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PatternResultContract"
            }
          },
          "next": {
            "type": "string"
          }
        }
      },
      "TextBlock": {
        "required": [
          "bounds",
          "content"
        ],
        "type": "object",
        "properties": {
          "bounds": {
            "$ref": "#/components/schemas/PdfBounds"
          },
          "content": {
            "type": "string"
          }
        }
      },
      "TicketClosedContract": {
        "required": [
          "ticketId",
          "filesReceived",
          "closed",
          "next"
        ],
        "type": "object",
        "properties": {
          "ticketId": {
            "type": "string"
          },
          "filesReceived": {
            "type": "integer",
            "format": "int32"
          },
          "closed": {
            "type": "boolean"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "TicketContract": {
        "required": [
          "ticketId",
          "uploadUrl",
          "token",
          "expiresUtc",
          "maxFiles",
          "maxBytes",
          "script",
          "curl",
          "next"
        ],
        "type": "object",
        "properties": {
          "ticketId": {
            "type": "string"
          },
          "uploadUrl": {
            "type": "string"
          },
          "token": {
            "type": "string"
          },
          "expiresUtc": {
            "type": "string",
            "format": "date-time"
          },
          "maxFiles": {
            "type": "integer",
            "format": "int32"
          },
          "maxBytes": {
            "type": "integer",
            "format": "int64"
          },
          "script": {
            "type": "string"
          },
          "curl": {
            "type": "string"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "UnsatisfiedRequirement": {
        "required": [
          "kind",
          "reason"
        ],
        "type": "object",
        "properties": {
          "kind": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "ValidateContract": {
        "required": [
          "valid",
          "errors",
          "draftHandle",
          "patternsProven",
          "next"
        ],
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean"
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateValidationError"
            }
          },
          "draftHandle": {
            "type": "string",
            "nullable": true
          },
          "patternsProven": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "next": {
            "type": "string"
          }
        }
      },
      "ValidationSeverity": {
        "enum": [
          "info",
          "warning",
          "error"
        ],
        "type": "string"
      }
    },
    "responses": {
      "Problem": {
        "description": "The call was refused or failed: code names the error, title says what went wrong, and detail is the next step.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "connectionKey": {
        "type": "http",
        "description": "A connection key (dk_...) sent as Authorization: Bearer <key>.",
        "scheme": "bearer"
      },
      "oauth2": {
        "type": "oauth2",
        "description": "Sign in with the Docuoria account.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://api.docuoria.com/oauth/authorize",
            "tokenUrl": "https://api.docuoria.com/oauth/token",
            "scopes": {
              "docuoria": "Call the Docuoria tools as the signed-in account."
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "connectionKey": []
    },
    {
      "oauth2": [
        "docuoria"
      ]
    }
  ],
  "tags": [
    {
      "name": "Handoff"
    },
    {
      "name": "Extraction"
    },
    {
      "name": "Authoring"
    },
    {
      "name": "Templates"
    },
    {
      "name": "Ledgers"
    },
    {
      "name": "Account"
    },
    {
      "name": "Guidance"
    }
  ]
}
