{
  "openapi": "3.1.0",
  "info": {
    "title": "Temlavo Invoice Extraction API",
    "version": "1.0.0",
    "description": "AI-extracted invoice data with practical consistency checks, duplicate signals, and predictable asynchronous integration."
  },
  "servers": [{ "url": "https://api.temlavo.com" }],
  "paths": {
    "/v1/documents": {
      "post": {
        "operationId": "createDocument",
        "summary": "Create an invoice document and upload authorization",
        "security": [{ "ApiKeyAuth": [] }],
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": { "$ref": "#/components/schemas/IdempotencyKey" },
            "required": false,
            "description": "Strongly recommended: one key per invoice, in printable ASCII without spaces or commas. Retries must send the same key and the same body; changing the body under a key that is still active returns `idempotency_conflict`."
          },
          {
            "in": "header",
            "name": "Temlavo-Upload-Recovery",
            "schema": { "type": "string", "const": "confirm-existing" },
            "required": false,
            "description": "Lets a retry recover a file that already uploaded: an exact retry of a document still waiting for its file returns `upload: null` once the file exists. Call [Confirm upload](https://temlavo.com/docs/api-reference/confirm-upload) before uploading again. Creating a document never starts processing."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CreateDocumentRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A retry with the same key and body. It returns the existing document, which may include a fresh upload URL while it still waits for its file. If it returns `awaiting_upload`, call [upload-complete](https://temlavo.com/docs/api-reference/confirm-upload) before uploading again: the file may already have arrived.",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Cache-Control": {
                "required": true,
                "schema": { "type": "string", "const": "no-store" },
                "description": "Prevents caching of signed capabilities and one-time secrets"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateDocumentReplayResponse"
                }
              }
            }
          },
          "201": {
            "description": "The document is `awaiting_upload`, and `upload` says where and how to send the file.",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Cache-Control": {
                "required": true,
                "schema": { "type": "string", "const": "no-store" },
                "description": "Prevents caching of signed capabilities and one-time secrets"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateDocumentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`, `invalid_callback_url`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "401": {
            "description": "Error: `invalid_api_key`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "402": {
            "description": "Error: `billing_required`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "404": {
            "description": "Error: `document_not_found`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_conflict`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "410": {
            "description": "Error: `upload_expired`, `document_expired`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "413": {
            "description": "Error: `document_too_large`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_content_type`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limit_exceeded`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Retry-After": {
                "required": true,
                "description": "Seconds to wait before retrying or polling",
                "schema": {
                  "type": "string",
                  "description": "Seconds to wait before retrying or polling"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "500": {
            "description": "Error: `internal_error`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "503": {
            "description": "Error: `service_unavailable`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "description": "Seconds to wait before retrying or polling"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        },
        "x-error-codes": {
          "400": ["invalid_request", "invalid_callback_url"],
          "401": ["invalid_api_key"],
          "402": ["billing_required"],
          "404": ["document_not_found"],
          "409": ["idempotency_conflict"],
          "410": ["upload_expired", "document_expired"],
          "413": ["document_too_large"],
          "415": ["unsupported_content_type"],
          "429": ["rate_limit_exceeded"],
          "500": ["internal_error"],
          "503": ["service_unavailable"]
        }
      }
    },
    "/v1/documents/{document_id}/upload-complete": {
      "post": {
        "operationId": "completeDocumentUpload",
        "summary": "Confirm a direct upload and admit it for processing",
        "security": [{ "ApiKeyAuth": [] }],
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "schema": {
              "description": "The `doc_…` ID that [create document](https://temlavo.com/docs/api-reference/create-document) returned.",
              "$ref": "#/components/schemas/DocumentId"
            },
            "required": true,
            "description": "The `doc_…` ID that [create document](https://temlavo.com/docs/api-reference/create-document) returned."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/UploadCompleteRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A confirmation replay. It returns the existing `queued`, `processing` or terminal document; no second processing run is created. Poll the document while it is pending, or handle its terminal result; do not upload again.",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Cache-Control": {
                "required": true,
                "schema": { "type": "string", "const": "no-store" },
                "description": "Prevents caching of signed capabilities and one-time secrets"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadCompleteReplayResponse"
                }
              }
            }
          },
          "202": {
            "description": "The uploaded file passed its checks and the document is `queued`. Processing runs in the background.",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Cache-Control": {
                "required": true,
                "schema": { "type": "string", "const": "no-store" },
                "description": "Prevents caching of signed capabilities and one-time secrets"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadCompleteAcceptedResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "401": {
            "description": "Error: `invalid_api_key`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "402": {
            "description": "Error: `billing_required`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "404": {
            "description": "Error: `document_not_found`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "409": {
            "description": "Error: `upload_not_complete`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "410": {
            "description": "Error: `upload_expired`, `document_expired`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "413": {
            "description": "Error: `document_too_large`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_content_type`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "422": {
            "description": "Error: `upload_size_mismatch`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limit_exceeded`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Retry-After": {
                "required": true,
                "description": "Seconds to wait before retrying or polling",
                "schema": {
                  "type": "string",
                  "description": "Seconds to wait before retrying or polling"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "500": {
            "description": "Error: `internal_error`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "503": {
            "description": "Error: `service_unavailable`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "description": "Seconds to wait before retrying or polling"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        },
        "x-error-codes": {
          "400": ["invalid_request"],
          "401": ["invalid_api_key"],
          "402": ["billing_required"],
          "404": ["document_not_found"],
          "409": ["upload_not_complete"],
          "410": ["upload_expired", "document_expired"],
          "413": ["document_too_large"],
          "415": ["unsupported_content_type"],
          "422": ["upload_size_mismatch"],
          "429": ["rate_limit_exceeded"],
          "500": ["internal_error"],
          "503": ["service_unavailable"]
        }
      }
    },
    "/v1/documents/{document_id}": {
      "get": {
        "operationId": "getDocument",
        "summary": "Retrieve the current document resource",
        "security": [{ "ApiKeyAuth": [] }],
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "schema": {
              "description": "The `doc_…` ID that [create document](https://temlavo.com/docs/api-reference/create-document) returned.",
              "$ref": "#/components/schemas/DocumentId"
            },
            "required": true,
            "description": "The `doc_…` ID that [create document](https://temlavo.com/docs/api-reference/create-document) returned."
          }
        ],
        "responses": {
          "200": {
            "description": "The document. Which fields it has depends on its `status`.",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Cache-Control": {
                "required": true,
                "schema": { "type": "string", "const": "no-store" },
                "description": "Prevents caching of signed capabilities and one-time secrets"
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "description": "Seconds to wait before retrying or polling"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/DocumentResponse" }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "401": {
            "description": "Error: `invalid_api_key`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "404": {
            "description": "Error: `document_not_found`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "410": {
            "description": "Error: `document_expired`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limit_exceeded`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Retry-After": {
                "required": true,
                "description": "Seconds to wait before retrying or polling",
                "schema": {
                  "type": "string",
                  "description": "Seconds to wait before retrying or polling"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "500": {
            "description": "Error: `internal_error`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        },
        "x-error-codes": {
          "400": ["invalid_request"],
          "401": ["invalid_api_key"],
          "404": ["document_not_found"],
          "410": ["document_expired"],
          "429": ["rate_limit_exceeded"],
          "500": ["internal_error"]
        }
      },
      "delete": {
        "operationId": "deleteDocument",
        "summary": "Delete a document and its retained customer content",
        "security": [{ "ApiKeyAuth": [] }],
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "schema": {
              "description": "The `doc_…` ID that [create document](https://temlavo.com/docs/api-reference/create-document) returned.",
              "$ref": "#/components/schemas/DocumentId"
            },
            "required": true,
            "description": "The `doc_…` ID that [create document](https://temlavo.com/docs/api-reference/create-document) returned."
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted from the API, with no body. Stored results and document fields are cleared; physical storage cleanup may still be pending.",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "401": {
            "description": "Error: `invalid_api_key`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "404": {
            "description": "Error: `document_not_found`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limit_exceeded`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Retry-After": {
                "required": true,
                "description": "Seconds to wait before retrying or polling",
                "schema": {
                  "type": "string",
                  "description": "Seconds to wait before retrying or polling"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "500": {
            "description": "Error: `internal_error`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        },
        "x-error-codes": {
          "400": ["invalid_request"],
          "401": ["invalid_api_key"],
          "404": ["document_not_found"],
          "429": ["rate_limit_exceeded"],
          "500": ["internal_error"]
        }
      }
    },
    "/v1/usage": {
      "get": {
        "operationId": "getUsage",
        "summary": "Retrieve current or historical processing usage",
        "security": [{ "ApiKeyAuth": [] }],
        "parameters": [
          {
            "in": "query",
            "name": "accounting_entity_id",
            "schema": { "$ref": "#/components/schemas/AccountingEntityId" },
            "required": false,
            "description": "Attribute finalized processed pages to one of your accounting entities. This adds an `attribution` breakdown; account totals stay the same."
          },
          {
            "in": "query",
            "name": "periods_ago",
            "schema": { "$ref": "#/components/schemas/PeriodsAgo" },
            "required": false,
            "description": "A closed billing period to report, counted back from the current one: `1` is the most recently closed retained period. Omit it for the current period."
          }
        ],
        "responses": {
          "200": {
            "description": "The usage report for the requested period.",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/UsageResponse" }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "401": {
            "description": "Error: `invalid_api_key`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "404": {
            "description": "Error: `usage_period_not_found`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limit_exceeded`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              },
              "Retry-After": {
                "required": true,
                "description": "Seconds to wait before retrying or polling",
                "schema": {
                  "type": "string",
                  "description": "Seconds to wait before retrying or polling"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "500": {
            "description": "Error: `internal_error`",
            "headers": {
              "X-Request-Id": {
                "required": true,
                "description": "Request identifier for support and diagnostics",
                "schema": {
                  "description": "Request identifier for support and diagnostics",
                  "$ref": "#/components/schemas/RequestId"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        },
        "x-error-codes": {
          "400": ["invalid_request"],
          "401": ["invalid_api_key"],
          "404": ["usage_period_not_found"],
          "429": ["rate_limit_exceeded"],
          "500": ["internal_error"]
        }
      }
    }
  },
  "components": {
    "schemas": {
      "IdempotencyKey": {
        "type": "string",
        "pattern": "^[\\x21-\\x2B\\x2D-\\x7E]+$",
        "minLength": 1,
        "maxLength": 255
      },
      "CreateDocumentRequest": {
        "type": "object",
        "properties": {
          "filename": {
            "description": "The original filename, without surrounding spaces or control characters. It is kept as document metadata only; storage paths never contain it.",
            "$ref": "#/components/schemas/Filename"
          },
          "content_type": {
            "description": "Must match the bytes you upload.",
            "$ref": "#/components/schemas/SourceContentType"
          },
          "file_size_bytes": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 20971520,
            "description": "Exact size of the file you will upload, up to 20 MiB. Confirm upload checks the stored file against it."
          },
          "external_id": {
            "description": "Your own reference. It is returned on every document response so you can match the document to records in your system.",
            "$ref": "#/components/schemas/ExternalId"
          },
          "accounting_entity_id": {
            "description": "An opaque, case-sensitive namespace of your own, such as a client ID. Duplicate detection is isolated within it and usage can be attributed to it; it is not an authorization boundary.",
            "$ref": "#/components/schemas/AccountingEntityId"
          },
          "policy": {
            "description": "How findings affect this document's review outcome. Omitted members get their defaults; null, unknown members and unsupported values are rejected. The accepted policy is returned on every response. See [review policy](https://temlavo.com/docs/review-policy) for how each setting works.",
            "$ref": "#/components/schemas/CreateDocumentPolicy"
          },
          "callback_url": {
            "description": "Notified when this document finishes. HTTPS on port 443, with no credentials or fragment. The callback is a notification, not the result: [fetch the document before acting on it](https://temlavo.com/docs/errors-recovery#callbacks). Keep sensitive values out of the URL; hosting platform logs may retain it.",
            "$ref": "#/components/schemas/CallbackUrl"
          },
          "metadata": {
            "default": {},
            "description": "Your own key/value pairs, preserved exactly. Keys use ASCII letters, digits, `_`, `.` or `-`; values are single-line strings.",
            "$ref": "#/components/schemas/CustomerMetadata"
          }
        },
        "required": ["filename", "content_type", "file_size_bytes"],
        "additionalProperties": false
      },
      "Filename": {
        "type": "string",
        "description": "Filename with 1..255 Unicode code points, no surrounding whitespace, and no Cc/U+2028/U+2029 control characters",
        "minLength": 1,
        "maxLength": 255
      },
      "SourceContentType": {
        "type": "string",
        "enum": ["application/pdf", "image/jpeg", "image/png"]
      },
      "ExternalId": {
        "type": "string",
        "description": "Opaque external ID with 1..255 Unicode code points, no surrounding whitespace, and no Cc/U+2028/U+2029 control characters",
        "minLength": 1,
        "maxLength": 255
      },
      "AccountingEntityId": {
        "type": "string",
        "description": "Opaque case-sensitive accounting entity namespace with 1..255 Unicode code points, no surrounding whitespace, and no Cc/U+2028/U+2029 control characters",
        "minLength": 1,
        "maxLength": 255
      },
      "RequiredFieldPath": {
        "type": "string",
        "enum": [
          "/data/customer/name",
          "/data/customer/tax_id",
          "/data/invoice/currency",
          "/data/invoice/due_date",
          "/data/invoice/issue_date",
          "/data/invoice/number",
          "/data/invoice/payment_terms",
          "/data/invoice/purchase_order_number",
          "/data/totals/amount_due",
          "/data/totals/discount",
          "/data/totals/other_charges",
          "/data/totals/shipping",
          "/data/totals/subtotal",
          "/data/totals/tax",
          "/data/totals/total",
          "/data/vendor/name",
          "/data/vendor/tax_id"
        ]
      },
      "LineItemsPolicy": {
        "type": "string",
        "enum": ["advisory", "review_on_failure", "required"],
        "x-enumDescriptions": {
          "advisory": "Eligible row findings stay warnings and don't block completion.",
          "review_on_failure": "Row calculation failures, conflicting row values, and rows that add up to neither the subtotal nor the total require review. Missing rows alone don't.",
          "required": "Row failures block, and the result also needs complete line items: at least one row, each with a line total and a description or product code."
        }
      },
      "CreateDocumentPolicy": {
        "default": {
          "required_fields": [],
          "line_items": "advisory",
          "checks": { "duplicate_detection": true }
        },
        "type": "object",
        "properties": {
          "required_fields": {
            "default": [],
            "description": "Invoice fields that must be present, as JSON Pointer paths such as `/data/invoice/purchase_order_number`. A required field that comes back null makes the document need review. See [the fields you can require](https://temlavo.com/docs/schema#required-fields).",
            "title": "Required fields",
            "maxItems": 17,
            "type": "array",
            "items": { "$ref": "#/components/schemas/RequiredFieldPath" },
            "uniqueItems": true
          },
          "line_items": {
            "default": "advisory",
            "description": "How line-item findings affect review, and whether usable line items are required.",
            "title": "Line-item policy",
            "$ref": "#/components/schemas/LineItemsPolicy"
          },
          "checks": {
            "default": { "duplicate_detection": true },
            "description": "Checks for this document.",
            "type": "object",
            "properties": {
              "duplicate_detection": {
                "default": true,
                "description": "Whether this document takes part in duplicate checks. `false` skips both duplicate checks and adds nothing to your duplicate history.",
                "title": "Duplicate detection",
                "type": "boolean"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "CallbackUrl": {
        "type": "string",
        "description": "HTTPS callback URL using a DNS hostname and port 443, with 1..2048 Unicode code points, no fragment, no surrounding whitespace, no embedded credentials, and no Cc/U+2028/U+2029 control characters",
        "minLength": 1,
        "maxLength": 2048,
        "format": "uri",
        "pattern": "^[Hh][Tt][Tt][Pp][Ss]://"
      },
      "CustomerMetadata": {
        "type": "object",
        "propertyNames": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.-]+$",
          "description": "Metadata key containing 1..64 ASCII letters, digits, _, ., or -",
          "minLength": 1,
          "maxLength": 64
        },
        "additionalProperties": {
          "type": "string",
          "description": "Opaque string preserved exactly, limited to 500 Unicode code points and required to be single-line/control-free (no Cc/U+2028/U+2029)",
          "maxLength": 500
        },
        "maxProperties": 10
      },
      "DocumentId": { "type": "string", "pattern": "^doc_.+$" },
      "UploadCompleteRequest": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "PeriodsAgo": {
        "type": "string",
        "pattern": "^[1-9][0-9]{0,8}$",
        "minimum": 1,
        "maximum": 999999999
      },
      "EventId": { "type": "string", "pattern": "^evt_.+$" },
      "UtcDateTime": {
        "type": "string",
        "format": "date-time",
        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
      },
      "ApiRequestIssue": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "minLength": 1,
            "description": "Where the input is: `body`, `query`, `header`, or `path`."
          },
          "path": {
            "type": "string",
            "description": "A JSON Pointer to the input, such as `/policy/line_items`."
          },
          "code": {
            "type": "string",
            "minLength": 1,
            "description": "A stable code to branch on. See [the request issue codes](https://temlavo.com/docs/errors-recovery#field-issues)."
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "description": "An explanation for people. Never branch on it."
          }
        },
        "required": ["location", "path", "code", "message"],
        "additionalProperties": true,
        "description": "One rejected request input: where it is (location and an RFC 6901 JSON Pointer path), a stable code and a message for people."
      },
      "RequestId": { "type": "string", "pattern": "^req_.+$" },
      "CreateDocumentReplayResponse": {
        "anyOf": [
          { "$ref": "#/components/schemas/CreateDocumentResponse" },
          { "$ref": "#/components/schemas/ConfirmExistingUploadResponse" },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "queued",
                "x-enumDescriptions": {
                  "queued": "The file passed admission; processing is waiting to begin."
                },
                "description": "Where the document is in processing."
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "processing",
                "x-enumDescriptions": {
                  "processing": "Processing is underway."
                },
                "description": "Where the document is in processing."
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "completed",
                "x-enumDescriptions": {
                  "completed": "A usable result with no blocking check. Warnings may remain."
                },
                "description": "Where the document is in processing."
              },
              "completed_at": {
                "description": "When processing finished.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "document": {
                "description": "The uploaded file.",
                "$ref": "#/components/schemas/ResultDocumentDescriptor"
              },
              "data": {
                "description": "The extracted invoice. See the [invoice.v1 reference](https://temlavo.com/docs/schema) for every field.",
                "$ref": "#/components/schemas/InvoiceDataV1"
              },
              "validation": {
                "description": "The checks run on the result.",
                "$ref": "#/components/schemas/Validation"
              },
              "processing": {
                "description": "How the result was produced and how long it is kept.",
                "$ref": "#/components/schemas/ProcessingMetadata"
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status",
              "completed_at",
              "document",
              "data",
              "validation",
              "processing"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "needs_review",
                "x-enumDescriptions": {
                  "needs_review": "A usable result with at least one blocking check."
                },
                "description": "Where the document is in processing."
              },
              "completed_at": {
                "description": "When processing finished.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "document": {
                "description": "The uploaded file.",
                "$ref": "#/components/schemas/ResultDocumentDescriptor"
              },
              "data": {
                "description": "The extracted invoice. See the [invoice.v1 reference](https://temlavo.com/docs/schema) for every field.",
                "$ref": "#/components/schemas/InvoiceDataV1"
              },
              "validation": {
                "description": "The checks run on the result.",
                "$ref": "#/components/schemas/Validation"
              },
              "processing": {
                "description": "How the result was produced and how long it is kept.",
                "$ref": "#/components/schemas/ProcessingMetadata"
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status",
              "completed_at",
              "document",
              "data",
              "validation",
              "processing"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "failed",
                "x-enumDescriptions": {
                  "failed": "No usable result was produced. This status is final."
                },
                "description": "Where the document is in processing."
              },
              "completed_at": {
                "description": "When processing finished.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "document": {
                "description": "The uploaded file.",
                "$ref": "#/components/schemas/FailedDocumentDescriptor"
              },
              "error": {
                "description": "Why the document failed.",
                "$ref": "#/components/schemas/AsyncDocumentError"
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status",
              "completed_at",
              "document",
              "error"
            ],
            "additionalProperties": true
          }
        ]
      },
      "CreateDocumentResponse": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The document's ID.",
            "$ref": "#/components/schemas/DocumentId"
          },
          "object": {
            "type": "string",
            "const": "document",
            "description": "The resource type."
          },
          "status": {
            "type": "string",
            "const": "awaiting_upload",
            "x-enumDescriptions": {
              "awaiting_upload": "Waiting for the file. Processing has not been admitted yet."
            },
            "description": "Where the document is in processing."
          },
          "document_type": {
            "type": "string",
            "const": "invoice",
            "description": "The kind of document."
          },
          "schema_version": {
            "type": "string",
            "const": "invoice.v1",
            "description": "The version of the `data` schema."
          },
          "created_at": {
            "description": "When the document was created.",
            "$ref": "#/components/schemas/UtcDateTime"
          },
          "external_id": {
            "anyOf": [
              { "$ref": "#/components/schemas/ExternalId" },
              { "type": "null" }
            ],
            "description": "Your own reference from create document, or null."
          },
          "accounting_entity_id": {
            "anyOf": [
              { "$ref": "#/components/schemas/AccountingEntityId" },
              { "type": "null" }
            ],
            "description": "Your accounting entity from create document, or null."
          },
          "policy": {
            "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
            "$ref": "#/components/schemas/DocumentPolicy"
          },
          "upload": {
            "description": "Where and how to upload the file to private storage. It is null only on an exact retry sent with `Temlavo-Upload-Recovery` once the file exists.",
            "$ref": "#/components/schemas/UploadAuthorization"
          },
          "callback": {
            "anyOf": [
              { "$ref": "#/components/schemas/CallbackDeliverySummary" },
              { "type": "null" }
            ],
            "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
          },
          "metadata": {
            "description": "Your key/value pairs from create document, unchanged.",
            "$ref": "#/components/schemas/CustomerMetadata"
          }
        },
        "required": [
          "id",
          "object",
          "status",
          "document_type",
          "schema_version",
          "created_at",
          "external_id",
          "accounting_entity_id",
          "policy",
          "upload",
          "callback",
          "metadata"
        ],
        "additionalProperties": true
      },
      "DocumentPolicy": {
        "type": "object",
        "properties": {
          "required_fields": {
            "maxItems": 17,
            "type": "array",
            "items": { "$ref": "#/components/schemas/RequiredFieldPath" },
            "description": "Invoice fields that must be present, as JSON Pointer paths such as `/data/invoice/purchase_order_number`. A required field that comes back null makes the document need review. See [the fields you can require](https://temlavo.com/docs/schema#required-fields).",
            "title": "Required fields",
            "uniqueItems": true
          },
          "line_items": {
            "description": "How line-item findings affect review, and whether usable line items are required.",
            "title": "Line-item policy",
            "$ref": "#/components/schemas/LineItemsPolicy"
          },
          "checks": {
            "type": "object",
            "properties": {
              "duplicate_detection": {
                "type": "boolean",
                "description": "Whether this document takes part in duplicate checks. `false` skips both duplicate checks and adds nothing to your duplicate history.",
                "title": "Duplicate detection"
              }
            },
            "required": ["duplicate_detection"],
            "additionalProperties": false,
            "description": "Checks for this document."
          }
        },
        "required": ["required_fields", "line_items", "checks"],
        "additionalProperties": false
      },
      "HttpsUrl": {
        "type": "string",
        "format": "uri",
        "pattern": "^https:\\/\\/.*",
        "description": "Public HTTPS URL without embedded username or password credentials"
      },
      "UploadAuthorization": {
        "type": "object",
        "properties": {
          "method": {
            "type": "string",
            "const": "PUT",
            "description": "The HTTP method for the upload."
          },
          "url": {
            "description": "The signed upload URL.",
            "$ref": "#/components/schemas/HttpsUrl"
          },
          "headers": {
            "type": "object",
            "propertyNames": { "type": "string" },
            "additionalProperties": { "type": "string" },
            "description": "Headers to send with the upload, exactly as given."
          },
          "expires_at": {
            "description": "When the signed URL stops accepting the upload.",
            "$ref": "#/components/schemas/UtcDateTime"
          }
        },
        "required": ["method", "url", "headers", "expires_at"],
        "additionalProperties": true
      },
      "CallbackDeliverySummary": {
        "type": "object",
        "properties": {
          "event_id": {
            "anyOf": [
              { "type": "string", "pattern": "^evt_.+" },
              { "type": "null" }
            ],
            "description": "The `document.finished` event's ID, or null before there is one. Check that it matches the callback you received."
          },
          "status": {
            "type": "string",
            "enum": ["pending", "delivered", "failed"],
            "x-enumDescriptions": {
              "pending": "Delivery is underway or will be retried.",
              "delivered": "Your callback URL accepted the event.",
              "failed": "A permanent failure, or attempts or time ran out. The document itself is unaffected."
            },
            "description": "Where delivery stands."
          },
          "attempt_count": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Delivery attempts so far."
          },
          "last_attempt_at": {
            "anyOf": [
              { "$ref": "#/components/schemas/UtcDateTime" },
              { "type": "null" }
            ],
            "description": "When the last attempt was made."
          },
          "next_attempt_at": {
            "anyOf": [
              { "$ref": "#/components/schemas/UtcDateTime" },
              { "type": "null" }
            ],
            "description": "When the next attempt is due, while delivery is pending."
          },
          "last_http_status": {
            "anyOf": [
              { "type": "integer", "minimum": 100, "maximum": 599 },
              { "type": "null" }
            ],
            "description": "The HTTP status your URL returned on the last attempt."
          },
          "last_error_code": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "Why the last attempt failed. See [callback delivery errors](https://temlavo.com/docs/errors-recovery#callback-errors)."
          },
          "delivered_at": {
            "anyOf": [
              { "$ref": "#/components/schemas/UtcDateTime" },
              { "type": "null" }
            ],
            "description": "When delivery succeeded."
          }
        },
        "required": [
          "event_id",
          "status",
          "attempt_count",
          "last_attempt_at",
          "next_attempt_at",
          "last_http_status",
          "last_error_code",
          "delivered_at"
        ],
        "additionalProperties": true
      },
      "ConfirmExistingUploadResponse": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The document's ID.",
            "$ref": "#/components/schemas/DocumentId"
          },
          "object": {
            "type": "string",
            "const": "document",
            "description": "The resource type."
          },
          "status": {
            "type": "string",
            "const": "awaiting_upload",
            "x-enumDescriptions": {
              "awaiting_upload": "Waiting for the file. Processing has not been admitted yet."
            },
            "description": "Where the document is in processing."
          },
          "document_type": {
            "type": "string",
            "const": "invoice",
            "description": "The kind of document."
          },
          "schema_version": {
            "type": "string",
            "const": "invoice.v1",
            "description": "The version of the `data` schema."
          },
          "created_at": {
            "description": "When the document was created.",
            "$ref": "#/components/schemas/UtcDateTime"
          },
          "external_id": {
            "anyOf": [
              { "$ref": "#/components/schemas/ExternalId" },
              { "type": "null" }
            ],
            "description": "Your own reference from create document, or null."
          },
          "accounting_entity_id": {
            "anyOf": [
              { "$ref": "#/components/schemas/AccountingEntityId" },
              { "type": "null" }
            ],
            "description": "Your accounting entity from create document, or null."
          },
          "policy": {
            "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
            "$ref": "#/components/schemas/DocumentPolicy"
          },
          "upload": {
            "type": "null",
            "description": "Where and how to upload the file to private storage. It is null only on an exact retry sent with `Temlavo-Upload-Recovery` once the file exists."
          },
          "callback": {
            "anyOf": [
              { "$ref": "#/components/schemas/CallbackDeliverySummary" },
              { "type": "null" }
            ],
            "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
          },
          "metadata": {
            "description": "Your key/value pairs from create document, unchanged.",
            "$ref": "#/components/schemas/CustomerMetadata"
          }
        },
        "required": [
          "id",
          "object",
          "status",
          "document_type",
          "schema_version",
          "created_at",
          "external_id",
          "accounting_entity_id",
          "policy",
          "upload",
          "callback",
          "metadata"
        ],
        "additionalProperties": true
      },
      "ResultDocumentDescriptor": {
        "type": "object",
        "properties": {
          "filename": {
            "description": "The filename from create document.",
            "$ref": "#/components/schemas/Filename"
          },
          "content_type": {
            "description": "The file's type.",
            "$ref": "#/components/schemas/SourceContentType"
          },
          "page_count": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "description": "The file's page count. It is null only when a failed file could not be counted."
          }
        },
        "required": ["filename", "content_type", "page_count"],
        "additionalProperties": true
      },
      "Address": {
        "type": "object",
        "properties": {
          "line1": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "First address line.",
            "title": "Address line 1"
          },
          "line2": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "Second address line.",
            "title": "Address line 2"
          },
          "city": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "City or town."
          },
          "region": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "State, province or region."
          },
          "postal_code": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "Postal or ZIP code.",
            "title": "Postal code"
          },
          "country_code": {
            "anyOf": [
              { "$ref": "#/components/schemas/CountryCode" },
              { "type": "null" }
            ],
            "description": "ISO 3166-1 alpha-2 code, such as `US`, when unambiguous.",
            "title": "Country"
          }
        },
        "required": [
          "line1",
          "line2",
          "city",
          "region",
          "postal_code",
          "country_code"
        ],
        "additionalProperties": false
      },
      "CountryCode": { "type": "string", "pattern": "^[A-Z]{2}$" },
      "InvoiceParty": {
        "type": "object",
        "properties": {
          "name": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "The name as printed, without trademark marks or trailing commas, semicolons and colons."
          },
          "tax_id": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "The tax ID. A printed scheme label such as `VAT No:` is removed when the identifier after it is clear.",
            "title": "Tax ID"
          },
          "address": {
            "anyOf": [
              { "$ref": "#/components/schemas/Address" },
              { "type": "null" }
            ],
            "description": "The postal address, or null when none is printed or none of its parts can be read."
          }
        },
        "required": ["name", "tax_id", "address"],
        "additionalProperties": false
      },
      "InvoiceDate": {
        "type": "string",
        "format": "date",
        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
      },
      "CurrencyCode": {
        "type": "string",
        "enum": [
          "ADP",
          "AED",
          "AFA",
          "AFN",
          "ALK",
          "ALL",
          "AMD",
          "ANG",
          "AOA",
          "AOK",
          "AON",
          "AOR",
          "ARA",
          "ARP",
          "ARS",
          "ARY",
          "ATS",
          "AUD",
          "AWG",
          "AYM",
          "AZM",
          "AZN",
          "BAD",
          "BAM",
          "BBD",
          "BDT",
          "BEC",
          "BEF",
          "BEL",
          "BGJ",
          "BGK",
          "BGL",
          "BGN",
          "BHD",
          "BIF",
          "BMD",
          "BND",
          "BOB",
          "BOP",
          "BOV",
          "BRB",
          "BRC",
          "BRE",
          "BRL",
          "BRN",
          "BRR",
          "BSD",
          "BTN",
          "BUK",
          "BWP",
          "BYB",
          "BYN",
          "BYR",
          "BZD",
          "CAD",
          "CDF",
          "CHC",
          "CHE",
          "CHF",
          "CHW",
          "CLF",
          "CLP",
          "CNY",
          "COP",
          "COU",
          "CRC",
          "CSD",
          "CSJ",
          "CSK",
          "CUC",
          "CUP",
          "CVE",
          "CYP",
          "CZK",
          "DDM",
          "DEM",
          "DJF",
          "DKK",
          "DOP",
          "DZD",
          "ECS",
          "ECV",
          "EEK",
          "EGP",
          "ERN",
          "ESA",
          "ESB",
          "ESP",
          "ETB",
          "EUR",
          "FIM",
          "FJD",
          "FKP",
          "FRF",
          "GBP",
          "GEK",
          "GEL",
          "GHC",
          "GHP",
          "GHS",
          "GIP",
          "GMD",
          "GNE",
          "GNF",
          "GNS",
          "GQE",
          "GRD",
          "GTQ",
          "GWE",
          "GWP",
          "GYD",
          "HKD",
          "HNL",
          "HRD",
          "HRK",
          "HTG",
          "HUF",
          "IDR",
          "IEP",
          "ILP",
          "ILR",
          "ILS",
          "INR",
          "IQD",
          "IRR",
          "ISJ",
          "ISK",
          "ITL",
          "JMD",
          "JOD",
          "JPY",
          "KES",
          "KGS",
          "KHR",
          "KMF",
          "KPW",
          "KRW",
          "KWD",
          "KYD",
          "KZT",
          "LAJ",
          "LAK",
          "LBP",
          "LKR",
          "LRD",
          "LSL",
          "LSM",
          "LTL",
          "LTT",
          "LUC",
          "LUF",
          "LUL",
          "LVL",
          "LVR",
          "LYD",
          "MAD",
          "MDL",
          "MGA",
          "MGF",
          "MKD",
          "MLF",
          "MMK",
          "MNT",
          "MOP",
          "MRO",
          "MRU",
          "MTL",
          "MTP",
          "MUR",
          "MVQ",
          "MVR",
          "MWK",
          "MXN",
          "MXP",
          "MXV",
          "MYR",
          "MZE",
          "MZM",
          "MZN",
          "NAD",
          "NGN",
          "NIC",
          "NIO",
          "NLG",
          "NOK",
          "NPR",
          "NZD",
          "OMR",
          "PAB",
          "PEH",
          "PEI",
          "PEN",
          "PES",
          "PGK",
          "PHP",
          "PKR",
          "PLN",
          "PLZ",
          "PTE",
          "PYG",
          "QAR",
          "RHD",
          "ROK",
          "ROL",
          "RON",
          "RSD",
          "RUB",
          "RUR",
          "RWF",
          "SAR",
          "SBD",
          "SCR",
          "SDD",
          "SDG",
          "SDP",
          "SEK",
          "SGD",
          "SHP",
          "SIT",
          "SKK",
          "SLE",
          "SLL",
          "SOS",
          "SRD",
          "SRG",
          "SSP",
          "STD",
          "STN",
          "SUR",
          "SVC",
          "SYP",
          "SZL",
          "THB",
          "TJR",
          "TJS",
          "TMM",
          "TMT",
          "TND",
          "TOP",
          "TPE",
          "TRL",
          "TRY",
          "TTD",
          "TWD",
          "TZS",
          "UAH",
          "UAK",
          "UGS",
          "UGW",
          "UGX",
          "USD",
          "USN",
          "USS",
          "UYI",
          "UYN",
          "UYP",
          "UYU",
          "UYW",
          "UZS",
          "VEB",
          "VED",
          "VEF",
          "VES",
          "VNC",
          "VND",
          "VUV",
          "WST",
          "XAD",
          "XAF",
          "XAG",
          "XAU",
          "XBA",
          "XBB",
          "XBC",
          "XBD",
          "XCD",
          "XCG",
          "XDR",
          "XEU",
          "XFO",
          "XFU",
          "XOF",
          "XPD",
          "XPF",
          "XPT",
          "XRE",
          "XSU",
          "XTS",
          "XUA",
          "XXX",
          "YDD",
          "YER",
          "YUD",
          "YUM",
          "YUN",
          "ZAL",
          "ZAR",
          "ZMK",
          "ZMW",
          "ZRN",
          "ZRZ",
          "ZWC",
          "ZWD",
          "ZWG",
          "ZWL",
          "ZWN",
          "ZWR"
        ]
      },
      "InvoiceHeader": {
        "type": "object",
        "properties": {
          "number": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "The invoice number. A leading `#` or `№` is removed; leading zeros stay.",
            "title": "Invoice number"
          },
          "issue_date": {
            "anyOf": [
              { "$ref": "#/components/schemas/InvoiceDate" },
              { "type": "null" }
            ],
            "description": "The issue date. Null when the printed date is ambiguous."
          },
          "due_date": {
            "anyOf": [
              { "$ref": "#/components/schemas/InvoiceDate" },
              { "type": "null" }
            ],
            "description": "The due date. Null when the printed date is ambiguous."
          },
          "purchase_order_number": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "The purchase order the invoice itself states or references, with a leading `#` or `№` removed. A separate purchase order page in the same upload never supplies it.",
            "title": "PO number"
          },
          "currency": {
            "anyOf": [
              { "$ref": "#/components/schemas/CurrencyCode" },
              { "type": "null" }
            ],
            "description": "The invoice currency: as printed, or inferred from the invoice's context. Null when the context is insufficient or contradictory."
          },
          "payment_terms": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "Payment terms as printed, such as `Net 30`."
          }
        },
        "required": [
          "number",
          "issue_date",
          "due_date",
          "purchase_order_number",
          "currency",
          "payment_terms"
        ],
        "additionalProperties": false
      },
      "LineItem": {
        "type": "object",
        "properties": {
          "description": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "The row's description, with wrapped lines merged."
          },
          "product_code": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "SKU, part or product code."
          },
          "quantity": {
            "anyOf": [
              { "$ref": "#/components/schemas/SignedDecimalString" },
              { "type": "null" }
            ],
            "description": "The row's quantity."
          },
          "unit_of_measure": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "The unit, such as `each` or `hours`."
          },
          "unit_price": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "The quoted amount per unit. It is never copied into or calculated from `line_total`."
          },
          "discount": {
            "anyOf": [
              { "$ref": "#/components/schemas/NonNegativeMoney" },
              { "type": "null" }
            ],
            "description": "The row's reduction."
          },
          "tax": {
            "anyOf": [
              { "$ref": "#/components/schemas/LineTax" },
              { "type": "null" }
            ],
            "description": "The row's tax, or null when the invoice shows no line tax. Several distinct line taxes without a printed aggregate leave it unknown; invoice-level breakdowns are in `taxes`."
          },
          "line_total": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "The row's extended amount as printed, never calculated. Credits and reversals keep their sign."
          }
        },
        "required": [
          "description",
          "product_code",
          "quantity",
          "unit_of_measure",
          "unit_price",
          "discount",
          "tax",
          "line_total"
        ],
        "additionalProperties": false
      },
      "SignedDecimalString": {
        "type": "string",
        "pattern": "^[+-]?\\d+(?:\\.\\d+)?$"
      },
      "Money": {
        "type": "object",
        "properties": {
          "amount": {
            "description": "The amount as a decimal string, with its sign.",
            "$ref": "#/components/schemas/SignedDecimalString"
          },
          "currency": {
            "description": "The amount's ISO 4217 currency code.",
            "$ref": "#/components/schemas/CurrencyCode"
          }
        },
        "required": ["amount", "currency"],
        "additionalProperties": false
      },
      "NonNegativeMoney": {
        "type": "object",
        "properties": {
          "amount": {
            "description": "The amount as a decimal string, never negative.",
            "$ref": "#/components/schemas/NonNegativeDecimalString"
          },
          "currency": {
            "description": "The amount's ISO 4217 currency code.",
            "$ref": "#/components/schemas/CurrencyCode"
          }
        },
        "required": ["amount", "currency"],
        "additionalProperties": false
      },
      "NonNegativeDecimalString": {
        "type": "string",
        "pattern": "^\\+?\\d+(?:\\.\\d+)?$"
      },
      "LineTax": {
        "type": "object",
        "properties": {
          "label": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "The tax label as printed."
          },
          "rate": {
            "anyOf": [
              { "$ref": "#/components/schemas/NonNegativeDecimalString" },
              { "type": "null" }
            ],
            "description": "As a decimal fraction: 8.25% is `0.0825`."
          },
          "amount": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "The row's tax amount."
          }
        },
        "required": ["label", "rate", "amount"],
        "additionalProperties": false
      },
      "LineItemsStatus": {
        "type": "string",
        "enum": ["complete", "partial", "unavailable"],
        "description": "AI assessment of line-item extraction. Complete is not independent proof that every source item was captured.",
        "x-enumDescriptions": {
          "complete": "The AI assessed the rows as complete. It is not proof that every source row was captured.",
          "partial": "Some rows were extracted and are kept; others are missing.",
          "unavailable": "Extraction yielded no rows and `line_items` is empty. It doesn't mean the invoice has none."
        }
      },
      "InvoiceTotals": {
        "type": "object",
        "properties": {
          "subtotal": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "The invoice charge base before invoice-level adjustments."
          },
          "discount": {
            "anyOf": [
              { "$ref": "#/components/schemas/NonNegativeMoney" },
              { "type": "null" }
            ],
            "description": "The invoice-level reduction, even when the invoice prints it with a minus sign."
          },
          "shipping": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "Shipping charges."
          },
          "other_charges": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "The signed net of other invoice-level adjustments, when their meaning is explicit."
          },
          "tax": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "Invoice-level tax. Its breakdown is in `taxes`."
          },
          "total": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "The invoice total after reductions, shipping, other charges and tax, before payments. When the invoice prints no total, it is the amount that its subtotal and adjustments, and its payable plus what was deducted from it, both give exactly; with nothing deducted, that is the payable."
          },
          "amount_due": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "The amount currently payable. Payments, deposits, credits and prior balances can make it differ from `total`."
          }
        },
        "required": [
          "subtotal",
          "discount",
          "shipping",
          "other_charges",
          "tax",
          "total",
          "amount_due"
        ],
        "additionalProperties": false
      },
      "TaxComponent": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["sales_tax", "vat", "gst", "other", "unknown"],
            "x-enumDescriptions": {
              "sales_tax": "Identified as sales tax.",
              "vat": "Identified as VAT.",
              "gst": "Identified as GST.",
              "other": "A clearly identified category other than sales tax, VAT or GST.",
              "unknown": "A real tax whose category can't be safely classified."
            },
            "description": "The tax category. It is never null: a real tax is kept even when its category can't be read."
          },
          "label": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "The tax label as printed."
          },
          "rate": {
            "anyOf": [
              { "$ref": "#/components/schemas/NonNegativeDecimalString" },
              { "type": "null" }
            ],
            "description": "As a decimal fraction: 8.25% is `0.0825`."
          },
          "taxable_amount": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "The amount the tax applies to."
          },
          "amount": {
            "anyOf": [
              { "$ref": "#/components/schemas/Money" },
              { "type": "null" }
            ],
            "description": "The tax amount. Null when none is printed, even when tax is known not to apply; it is never turned into zero."
          },
          "jurisdiction": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "The taxing jurisdiction, when printed."
          }
        },
        "required": [
          "type",
          "label",
          "rate",
          "taxable_amount",
          "amount",
          "jurisdiction"
        ],
        "additionalProperties": false
      },
      "InvoiceDataV1": {
        "type": "object",
        "properties": {
          "vendor": {
            "description": "The seller that issued the invoice.",
            "$ref": "#/components/schemas/InvoiceParty"
          },
          "customer": {
            "description": "The buyer the invoice is addressed to.",
            "$ref": "#/components/schemas/InvoiceParty"
          },
          "invoice": {
            "description": "The invoice header: its number, dates, purchase order, currency and payment terms.",
            "title": "Invoice details",
            "$ref": "#/components/schemas/InvoiceHeader"
          },
          "line_items": {
            "maxItems": 500,
            "type": "array",
            "items": { "$ref": "#/components/schemas/LineItem" },
            "description": "The invoice's billed rows."
          },
          "line_items_status": {
            "description": "How completely the rows were extracted. It is an AI assessment: `complete` is not proof that every source row was captured.",
            "title": "Line-item extraction",
            "$ref": "#/components/schemas/LineItemsStatus"
          },
          "totals": {
            "description": "Invoice-level amounts.",
            "$ref": "#/components/schemas/InvoiceTotals"
          },
          "taxes": {
            "maxItems": 500,
            "type": "array",
            "items": { "$ref": "#/components/schemas/TaxComponent" },
            "description": "The invoice-level tax breakdown, one entry per tax component.",
            "title": "Tax breakdown"
          }
        },
        "required": [
          "vendor",
          "customer",
          "invoice",
          "line_items",
          "line_items_status",
          "totals",
          "taxes"
        ],
        "additionalProperties": false,
        "if": {
          "properties": { "line_items_status": { "const": "unavailable" } },
          "required": ["line_items_status"]
        },
        "then": {
          "properties": { "line_items": { "type": "array", "maxItems": 0 } }
        }
      },
      "ValidationCheck": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "minLength": 1,
            "description": "The check that ran, such as `total_consistency`. New codes may be added; see [every check](https://temlavo.com/docs/checks)."
          },
          "status": {
            "type": "string",
            "enum": ["pass", "fail", "not_evaluable"],
            "x-enumDescriptions": {
              "pass": "The check passed.",
              "fail": "The check found a problem.",
              "not_evaluable": "The inputs were missing or unclear, so the check could not decide."
            },
            "description": "The outcome."
          },
          "severity": {
            "type": "string",
            "enum": ["info", "warning", "review"],
            "x-enumDescriptions": {
              "info": "Informational only.",
              "warning": "Worth a look; the result can still be completed.",
              "review": "Needs a person when the check fails or can't decide."
            },
            "description": "How much a failed check matters. A check blocks when its severity is `review` and its status is not `pass`."
          },
          "message": {
            "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }],
            "description": "An explanation for people, or null. Never branch on it."
          },
          "paths": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/InvoicePath" },
            "description": "The invoice fields the finding is about, such as `/data/totals/total`, so you can highlight them in your own review screen."
          },
          "details": {
            "description": "Check-specific data, such as the equation, calculated value and difference of an arithmetic check.",
            "anyOf": [
              { "$ref": "#/components/schemas/JsonValue" },
              { "type": "null" }
            ]
          }
        },
        "required": ["code", "status", "severity", "message", "paths"],
        "additionalProperties": true
      },
      "InvoicePath": { "type": "string", "pattern": "^\\/data\\/.+" },
      "JsonValue": { "$ref": "#/components/schemas/__schema0" },
      "Validation": {
        "type": "object",
        "properties": {
          "review_required": {
            "type": "boolean",
            "description": "`true` when at least one check blocks, which makes the status `needs_review`."
          },
          "checks": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/ValidationCheck" },
            "description": "Every check that ran, with its outcome. See [checks](https://temlavo.com/docs/checks)."
          }
        },
        "required": ["review_required", "checks"],
        "additionalProperties": true
      },
      "ProcessingMetadata": {
        "type": "object",
        "properties": {
          "pipeline_version": {
            "type": "string",
            "minLength": 1,
            "description": "The processing pipeline's version."
          },
          "duration_ms": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Processing time in milliseconds, from the start of processing until the result was stored. Upload, queue wait and callback delivery are not included.",
            "title": "Duration (ms)"
          },
          "processed_pages": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991,
            "description": "Pages counted for usage."
          },
          "result_expires_at": {
            "description": "When the retained result expires. After that, fetching the document returns [410 document_expired](https://temlavo.com/docs/errors-recovery#error-document_expired).",
            "$ref": "#/components/schemas/UtcDateTime"
          }
        },
        "required": [
          "pipeline_version",
          "duration_ms",
          "processed_pages",
          "result_expires_at"
        ],
        "additionalProperties": true
      },
      "FailedDocumentDescriptor": {
        "type": "object",
        "properties": {
          "filename": {
            "description": "The filename from create document.",
            "$ref": "#/components/schemas/Filename"
          },
          "content_type": {
            "description": "The file's type.",
            "$ref": "#/components/schemas/SourceContentType"
          },
          "page_count": {
            "anyOf": [
              {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              { "type": "null" }
            ],
            "description": "The file's page count. It is null only when a failed file could not be counted."
          }
        },
        "required": ["filename", "content_type", "page_count"],
        "additionalProperties": true
      },
      "AsyncDocumentError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "minLength": 1,
            "description": "A stable code. See [errors and recovery](https://temlavo.com/docs/errors-recovery#known-codes)."
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "description": "An explanation for people. Never branch on it."
          },
          "retryable": {
            "type": "boolean",
            "description": "Whether retrying could succeed. A failed document is final, so retrying it never restarts processing."
          },
          "docs_url": {
            "description": "The code's entry in the error reference. Show it to developers; never branch on it.",
            "$ref": "#/components/schemas/HttpsUrl"
          }
        },
        "required": ["code", "message", "retryable"],
        "additionalProperties": true
      },
      "ApiError": {
        "type": "object",
        "properties": {
          "error": {
            "description": "The error.",
            "$ref": "#/components/schemas/ApiErrorBody"
          }
        },
        "required": ["error"],
        "additionalProperties": true
      },
      "ApiErrorBody": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "minLength": 1,
            "description": "The error's broad category."
          },
          "code": {
            "type": "string",
            "minLength": 1,
            "description": "A stable code to branch on, with the HTTP status. See the [error catalogue](https://temlavo.com/docs/errors-recovery#known-codes)."
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "description": "An explanation for people. Never branch on it."
          },
          "request_id": {
            "description": "The request's ID, also sent as `X-Request-Id`. Give it to support.",
            "$ref": "#/components/schemas/RequestId"
          },
          "retryable": {
            "type": "boolean",
            "description": "Whether the same request may succeed later. Retry only when it is `true`, with backoff, waiting at least as long as `Retry-After` when the response sends it."
          },
          "docs_url": {
            "description": "The code's entry in the error reference. Show it to developers; never branch on it.",
            "$ref": "#/components/schemas/HttpsUrl"
          },
          "details": {
            "description": "Machine-readable details, when the code has them. For rejected inputs, `details.issues` lists [each rejected field](https://temlavo.com/docs/errors-recovery#field-issues).",
            "$ref": "#/components/schemas/JsonValue"
          }
        },
        "required": ["type", "code", "message", "request_id", "retryable"],
        "additionalProperties": true
      },
      "UploadCompleteReplayResponse": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "queued",
                "x-enumDescriptions": {
                  "queued": "The file passed admission; processing is waiting to begin."
                },
                "description": "Where the document is in processing."
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "processing",
                "x-enumDescriptions": {
                  "processing": "Processing is underway."
                },
                "description": "Where the document is in processing."
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "completed",
                "x-enumDescriptions": {
                  "completed": "A usable result with no blocking check. Warnings may remain."
                },
                "description": "Where the document is in processing."
              },
              "completed_at": {
                "description": "When processing finished.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "document": {
                "description": "The uploaded file.",
                "$ref": "#/components/schemas/ResultDocumentDescriptor"
              },
              "data": {
                "description": "The extracted invoice. See the [invoice.v1 reference](https://temlavo.com/docs/schema) for every field.",
                "$ref": "#/components/schemas/InvoiceDataV1"
              },
              "validation": {
                "description": "The checks run on the result.",
                "$ref": "#/components/schemas/Validation"
              },
              "processing": {
                "description": "How the result was produced and how long it is kept.",
                "$ref": "#/components/schemas/ProcessingMetadata"
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status",
              "completed_at",
              "document",
              "data",
              "validation",
              "processing"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "needs_review",
                "x-enumDescriptions": {
                  "needs_review": "A usable result with at least one blocking check."
                },
                "description": "Where the document is in processing."
              },
              "completed_at": {
                "description": "When processing finished.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "document": {
                "description": "The uploaded file.",
                "$ref": "#/components/schemas/ResultDocumentDescriptor"
              },
              "data": {
                "description": "The extracted invoice. See the [invoice.v1 reference](https://temlavo.com/docs/schema) for every field.",
                "$ref": "#/components/schemas/InvoiceDataV1"
              },
              "validation": {
                "description": "The checks run on the result.",
                "$ref": "#/components/schemas/Validation"
              },
              "processing": {
                "description": "How the result was produced and how long it is kept.",
                "$ref": "#/components/schemas/ProcessingMetadata"
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status",
              "completed_at",
              "document",
              "data",
              "validation",
              "processing"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "failed",
                "x-enumDescriptions": {
                  "failed": "No usable result was produced. This status is final."
                },
                "description": "Where the document is in processing."
              },
              "completed_at": {
                "description": "When processing finished.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "document": {
                "description": "The uploaded file.",
                "$ref": "#/components/schemas/FailedDocumentDescriptor"
              },
              "error": {
                "description": "Why the document failed.",
                "$ref": "#/components/schemas/AsyncDocumentError"
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status",
              "completed_at",
              "document",
              "error"
            ],
            "additionalProperties": true
          }
        ],
        "type": "object"
      },
      "UploadCompleteAcceptedResponse": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The document's ID.",
            "$ref": "#/components/schemas/DocumentId"
          },
          "object": {
            "type": "string",
            "const": "document",
            "description": "The resource type."
          },
          "document_type": {
            "type": "string",
            "const": "invoice",
            "description": "The kind of document."
          },
          "schema_version": {
            "type": "string",
            "const": "invoice.v1",
            "description": "The version of the `data` schema."
          },
          "created_at": {
            "description": "When the document was created.",
            "$ref": "#/components/schemas/UtcDateTime"
          },
          "external_id": {
            "anyOf": [
              { "$ref": "#/components/schemas/ExternalId" },
              { "type": "null" }
            ],
            "description": "Your own reference from create document, or null."
          },
          "accounting_entity_id": {
            "anyOf": [
              { "$ref": "#/components/schemas/AccountingEntityId" },
              { "type": "null" }
            ],
            "description": "Your accounting entity from create document, or null."
          },
          "policy": {
            "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
            "$ref": "#/components/schemas/DocumentPolicy"
          },
          "callback": {
            "anyOf": [
              { "$ref": "#/components/schemas/CallbackDeliverySummary" },
              { "type": "null" }
            ],
            "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
          },
          "metadata": {
            "description": "Your key/value pairs from create document, unchanged.",
            "$ref": "#/components/schemas/CustomerMetadata"
          },
          "status": {
            "type": "string",
            "const": "queued",
            "x-enumDescriptions": {
              "queued": "The file passed admission; processing is waiting to begin."
            },
            "description": "Where the document is in processing."
          }
        },
        "required": [
          "id",
          "object",
          "document_type",
          "schema_version",
          "created_at",
          "external_id",
          "accounting_entity_id",
          "policy",
          "callback",
          "metadata",
          "status"
        ],
        "additionalProperties": true
      },
      "DocumentResponse": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "awaiting_upload",
                "x-enumDescriptions": {
                  "awaiting_upload": "Waiting for the file. Processing has not been admitted yet."
                },
                "description": "Where the document is in processing."
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "queued",
                "x-enumDescriptions": {
                  "queued": "The file passed admission; processing is waiting to begin."
                },
                "description": "Where the document is in processing."
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "processing",
                "x-enumDescriptions": {
                  "processing": "Processing is underway."
                },
                "description": "Where the document is in processing."
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "completed",
                "x-enumDescriptions": {
                  "completed": "A usable result with no blocking check. Warnings may remain."
                },
                "description": "Where the document is in processing."
              },
              "completed_at": {
                "description": "When processing finished.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "document": {
                "description": "The uploaded file.",
                "$ref": "#/components/schemas/ResultDocumentDescriptor"
              },
              "data": {
                "description": "The extracted invoice. See the [invoice.v1 reference](https://temlavo.com/docs/schema) for every field.",
                "$ref": "#/components/schemas/InvoiceDataV1"
              },
              "validation": {
                "description": "The checks run on the result.",
                "$ref": "#/components/schemas/Validation"
              },
              "processing": {
                "description": "How the result was produced and how long it is kept.",
                "$ref": "#/components/schemas/ProcessingMetadata"
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status",
              "completed_at",
              "document",
              "data",
              "validation",
              "processing"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "needs_review",
                "x-enumDescriptions": {
                  "needs_review": "A usable result with at least one blocking check."
                },
                "description": "Where the document is in processing."
              },
              "completed_at": {
                "description": "When processing finished.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "document": {
                "description": "The uploaded file.",
                "$ref": "#/components/schemas/ResultDocumentDescriptor"
              },
              "data": {
                "description": "The extracted invoice. See the [invoice.v1 reference](https://temlavo.com/docs/schema) for every field.",
                "$ref": "#/components/schemas/InvoiceDataV1"
              },
              "validation": {
                "description": "The checks run on the result.",
                "$ref": "#/components/schemas/Validation"
              },
              "processing": {
                "description": "How the result was produced and how long it is kept.",
                "$ref": "#/components/schemas/ProcessingMetadata"
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status",
              "completed_at",
              "document",
              "data",
              "validation",
              "processing"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "description": "The document's ID.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "object": {
                "type": "string",
                "const": "document",
                "description": "The resource type."
              },
              "document_type": {
                "type": "string",
                "const": "invoice",
                "description": "The kind of document."
              },
              "schema_version": {
                "type": "string",
                "const": "invoice.v1",
                "description": "The version of the `data` schema."
              },
              "created_at": {
                "description": "When the document was created.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              },
              "policy": {
                "description": "The accepted [review policy](https://temlavo.com/docs/review-policy), with every member filled in.",
                "$ref": "#/components/schemas/DocumentPolicy"
              },
              "callback": {
                "anyOf": [
                  { "$ref": "#/components/schemas/CallbackDeliverySummary" },
                  { "type": "null" }
                ],
                "description": "Callback delivery, or null when no callback URL was set. See [callbacks](https://temlavo.com/docs/errors-recovery#callbacks)."
              },
              "metadata": {
                "description": "Your key/value pairs from create document, unchanged.",
                "$ref": "#/components/schemas/CustomerMetadata"
              },
              "status": {
                "type": "string",
                "const": "failed",
                "x-enumDescriptions": {
                  "failed": "No usable result was produced. This status is final."
                },
                "description": "Where the document is in processing."
              },
              "completed_at": {
                "description": "When processing finished.",
                "$ref": "#/components/schemas/UtcDateTime"
              },
              "document": {
                "description": "The uploaded file.",
                "$ref": "#/components/schemas/FailedDocumentDescriptor"
              },
              "error": {
                "description": "Why the document failed.",
                "$ref": "#/components/schemas/AsyncDocumentError"
              }
            },
            "required": [
              "id",
              "object",
              "document_type",
              "schema_version",
              "created_at",
              "external_id",
              "accounting_entity_id",
              "policy",
              "callback",
              "metadata",
              "status",
              "completed_at",
              "document",
              "error"
            ],
            "additionalProperties": true
          }
        ],
        "type": "object"
      },
      "UsageResponse": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "period": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "trial",
                    "x-enumDescriptions": { "trial": "The free trial." },
                    "description": "The kind of period."
                  },
                  "start": {
                    "description": "When the period starts.",
                    "$ref": "#/components/schemas/UtcDateTime"
                  },
                  "end": {
                    "description": "When the period ends.",
                    "$ref": "#/components/schemas/UtcDateTime"
                  }
                },
                "required": ["type", "start", "end"],
                "additionalProperties": false,
                "description": "The billing period reported. It is null only when there is no plan."
              },
              "plan": {
                "type": "string",
                "const": "trial",
                "x-enumDescriptions": { "trial": "The free trial." },
                "description": "The account's plan for this period."
              },
              "included_pages": {
                "type": "number",
                "const": 100,
                "description": "Pages the plan includes in this period.",
                "title": "Included"
              },
              "used_pages": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100,
                "description": "Processed pages counted in this period.",
                "title": "Used"
              },
              "remaining_pages": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100,
                "description": "Included pages left.",
                "title": "Remaining"
              },
              "overage_pages": {
                "type": "number",
                "const": 0,
                "description": "Pages beyond the included pages, on paid plans.",
                "title": "Overage"
              },
              "attribution": {
                "description": "Present when `accounting_entity_id` filters the report: the pages attributed to that entity. Account totals stay authoritative for billing.",
                "$ref": "#/components/schemas/UsageAttribution"
              }
            },
            "required": [
              "period",
              "plan",
              "included_pages",
              "used_pages",
              "remaining_pages",
              "overage_pages"
            ],
            "additionalProperties": true
          },
          {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "period": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "subscription",
                        "x-enumDescriptions": {
                          "subscription": "A paid subscription's billing period."
                        },
                        "description": "The kind of period."
                      },
                      "start": {
                        "description": "When the period starts.",
                        "$ref": "#/components/schemas/UtcDateTime"
                      },
                      "end": {
                        "description": "When the period ends.",
                        "$ref": "#/components/schemas/UtcDateTime"
                      }
                    },
                    "required": ["type", "start", "end"],
                    "additionalProperties": false,
                    "description": "The billing period reported. It is null only when there is no plan."
                  },
                  "plan": {
                    "type": "string",
                    "const": "starter",
                    "x-enumDescriptions": { "starter": "The Starter plan." },
                    "description": "The account's plan for this period."
                  },
                  "included_pages": {
                    "type": "number",
                    "const": 500,
                    "description": "Pages the plan includes in this period.",
                    "title": "Included"
                  },
                  "used_pages": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Processed pages counted in this period.",
                    "title": "Used"
                  },
                  "remaining_pages": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Included pages left.",
                    "title": "Remaining"
                  },
                  "overage_pages": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Pages beyond the included pages, on paid plans.",
                    "title": "Overage"
                  },
                  "attribution": {
                    "description": "Present when `accounting_entity_id` filters the report: the pages attributed to that entity. Account totals stay authoritative for billing.",
                    "$ref": "#/components/schemas/UsageAttribution"
                  }
                },
                "required": [
                  "period",
                  "plan",
                  "included_pages",
                  "used_pages",
                  "remaining_pages",
                  "overage_pages"
                ],
                "additionalProperties": true
              },
              {
                "type": "object",
                "properties": {
                  "period": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "subscription",
                        "x-enumDescriptions": {
                          "subscription": "A paid subscription's billing period."
                        },
                        "description": "The kind of period."
                      },
                      "start": {
                        "description": "When the period starts.",
                        "$ref": "#/components/schemas/UtcDateTime"
                      },
                      "end": {
                        "description": "When the period ends.",
                        "$ref": "#/components/schemas/UtcDateTime"
                      }
                    },
                    "required": ["type", "start", "end"],
                    "additionalProperties": false,
                    "description": "The billing period reported. It is null only when there is no plan."
                  },
                  "plan": {
                    "type": "string",
                    "const": "pro",
                    "x-enumDescriptions": { "pro": "The Pro plan." },
                    "description": "The account's plan for this period."
                  },
                  "included_pages": {
                    "type": "number",
                    "const": 3000,
                    "description": "Pages the plan includes in this period.",
                    "title": "Included"
                  },
                  "used_pages": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Processed pages counted in this period.",
                    "title": "Used"
                  },
                  "remaining_pages": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Included pages left.",
                    "title": "Remaining"
                  },
                  "overage_pages": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Pages beyond the included pages, on paid plans.",
                    "title": "Overage"
                  },
                  "attribution": {
                    "description": "Present when `accounting_entity_id` filters the report: the pages attributed to that entity. Account totals stay authoritative for billing.",
                    "$ref": "#/components/schemas/UsageAttribution"
                  }
                },
                "required": [
                  "period",
                  "plan",
                  "included_pages",
                  "used_pages",
                  "remaining_pages",
                  "overage_pages"
                ],
                "additionalProperties": true
              }
            ]
          },
          {
            "type": "object",
            "properties": {
              "period": {
                "type": "null",
                "description": "The billing period reported. It is null only when there is no plan."
              },
              "plan": {
                "type": "string",
                "const": "none",
                "x-enumDescriptions": {
                  "none": "No active plan; every count is zero."
                },
                "description": "The account's plan for this period."
              },
              "included_pages": {
                "type": "number",
                "const": 0,
                "description": "Pages the plan includes in this period.",
                "title": "Included"
              },
              "used_pages": {
                "type": "number",
                "const": 0,
                "description": "Processed pages counted in this period.",
                "title": "Used"
              },
              "remaining_pages": {
                "type": "number",
                "const": 0,
                "description": "Included pages left.",
                "title": "Remaining"
              },
              "overage_pages": {
                "type": "number",
                "const": 0,
                "description": "Pages beyond the included pages, on paid plans.",
                "title": "Overage"
              },
              "attribution": {
                "description": "Present when `accounting_entity_id` filters the report: the pages attributed to that entity. Account totals stay authoritative for billing.",
                "$ref": "#/components/schemas/UsageAttribution"
              }
            },
            "required": [
              "period",
              "plan",
              "included_pages",
              "used_pages",
              "remaining_pages",
              "overage_pages"
            ],
            "additionalProperties": true
          }
        ]
      },
      "UsageAttribution": {
        "type": "object",
        "properties": {
          "accounting_entity_id": {
            "description": "The entity you filtered by.",
            "$ref": "#/components/schemas/AccountingEntityId"
          },
          "processed_pages": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Processed pages attributed to it in this period."
          }
        },
        "required": ["accounting_entity_id", "processed_pages"],
        "additionalProperties": false
      },
      "__schema0": {
        "anyOf": [
          { "type": "string" },
          { "type": "number" },
          { "type": "boolean" },
          { "type": "null" },
          {
            "type": "array",
            "items": { "$ref": "#/components/schemas/__schema0" }
          },
          {
            "type": "object",
            "propertyNames": { "type": "string" },
            "additionalProperties": { "$ref": "#/components/schemas/__schema0" }
          }
        ]
      },
      "DocumentFinishedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's ID. The fetched document's `callback.event_id` matches it.",
            "$ref": "#/components/schemas/EventId"
          },
          "object": {
            "type": "string",
            "const": "event",
            "description": "The resource type."
          },
          "type": {
            "type": "string",
            "const": "document.finished",
            "description": "The event type."
          },
          "created_at": {
            "description": "When the event was created.",
            "$ref": "#/components/schemas/UtcDateTime"
          },
          "data": {
            "type": "object",
            "properties": {
              "document_id": {
                "description": "The document to fetch.",
                "$ref": "#/components/schemas/DocumentId"
              },
              "external_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/ExternalId" },
                  { "type": "null" }
                ],
                "description": "Your own reference from create document, or null."
              },
              "accounting_entity_id": {
                "anyOf": [
                  { "$ref": "#/components/schemas/AccountingEntityId" },
                  { "type": "null" }
                ],
                "description": "Your accounting entity from create document, or null."
              }
            },
            "required": ["document_id", "external_id", "accounting_entity_id"],
            "additionalProperties": false,
            "description": "Which document finished."
          }
        },
        "required": ["id", "object", "type", "created_at", "data"],
        "additionalProperties": false
      },
      "ApiErrorCode": {
        "type": "string",
        "enum": [
          "invalid_request",
          "invalid_callback_url",
          "invalid_api_key",
          "billing_required",
          "forbidden",
          "document_not_found",
          "idempotency_conflict",
          "upload_not_complete",
          "invalid_document_state",
          "upload_expired",
          "document_expired",
          "document_too_large",
          "unsupported_content_type",
          "upload_size_mismatch",
          "invalid_document",
          "usage_limit_exceeded",
          "usage_period_not_found",
          "rate_limit_exceeded",
          "internal_error",
          "service_unavailable"
        ]
      },
      "ApiErrorDetails": {
        "type": "object",
        "properties": {
          "issues": {
            "description": "Each rejected request input.",
            "type": "array",
            "items": { "$ref": "#/components/schemas/ApiRequestIssue" }
          }
        },
        "additionalProperties": true
      },
      "ApiRequestIssueCode": {
        "type": "string",
        "enum": [
          "required",
          "invalid_type",
          "invalid_value",
          "invalid_format",
          "too_large",
          "too_small",
          "unknown_field",
          "malformed",
          "invalid"
        ]
      },
      "ApiRequestIssueLocation": {
        "type": "string",
        "enum": ["body", "query", "header", "path"]
      },
      "AsyncDocumentErrorCode": {
        "type": "string",
        "enum": [
          "document_processing_failed",
          "processing_timeout",
          "invalid_document",
          "corrupt_pdf",
          "encrypted_pdf",
          "unsupported_document_type",
          "multiple_invoices_detected",
          "document_page_limit_exceeded",
          "document_complexity_limit_exceeded",
          "result_too_large",
          "ocr_failed",
          "semantic_extraction_failed",
          "usage_limit_exceeded",
          "billing_required"
        ]
      },
      "CallbackDeliveryErrorCode": {
        "type": "string",
        "enum": [
          "dns_error",
          "unsafe_destination",
          "connection_error",
          "timeout",
          "tls_error",
          "http_error",
          "response_too_large"
        ]
      },
      "ValidationCheckCode": {
        "type": "string",
        "enum": [
          "critical_field_unresolved",
          "required_field_unresolved",
          "semantic_issue",
          "document_classification",
          "line_item_arithmetic",
          "line_items_requirement",
          "tax_arithmetic",
          "total_consistency",
          "currency_consistency",
          "date_consistency",
          "exact_document_duplicate",
          "possible_invoice_duplicate",
          "line_items_sum_consistency",
          "amount_due_consistency",
          "tax_sum_consistency"
        ]
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Invoice API key"
      }
    }
  },
  "x-error-catalog": {
    "version": 1,
    "docs_url": "https://temlavo.com/docs/errors-recovery",
    "api_errors": {
      "invalid_request": {
        "http": {
          "status": 400,
          "type": "invalid_request",
          "message": "The request is invalid.",
          "retryable": false,
          "retry_after": null,
          "field_issues": true,
          "operations": [
            "createDocument",
            "completeDocumentUpload",
            "getDocument",
            "deleteDocument",
            "getUsage"
          ]
        },
        "recovery": "request-fields",
        "meaning": "The request body, headers, query parameters or path did not validate.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-invalid_request"
      },
      "invalid_callback_url": {
        "http": {
          "status": 400,
          "type": "invalid_request",
          "message": "The callback URL is invalid.",
          "retryable": false,
          "retry_after": null,
          "field_issues": true,
          "operations": ["createDocument"]
        },
        "recovery": "callback-url",
        "meaning": "The optional callback URL was rejected.",
        "note": "Returned when the callback URL is the only invalid body field; an oversized file or unsupported content type is reported first, and any other invalid field makes the request fail with `invalid_request`.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-invalid_callback_url"
      },
      "invalid_api_key": {
        "http": {
          "status": 401,
          "type": "authentication_error",
          "message": "Invalid API key.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": [
            "createDocument",
            "completeDocumentUpload",
            "getDocument",
            "deleteDocument",
            "getUsage"
          ]
        },
        "recovery": "authentication",
        "meaning": "The API key was not accepted.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-invalid_api_key"
      },
      "billing_required": {
        "http": {
          "status": 402,
          "type": "billing_error",
          "message": "A processing entitlement is required.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": ["createDocument", "completeDocumentUpload"]
        },
        "recovery": "billing",
        "meaning": "No active plan or allowance covers processing. A rejected upload-complete can be retried after you fix billing; a document that has already failed with this code cannot.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-billing_required"
      },
      "forbidden": {
        "http": {
          "status": 403,
          "type": "authentication_error",
          "message": "This request is not authorized.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": []
        },
        "recovery": "authentication",
        "meaning": "This account or key is not allowed to perform this operation.",
        "note": "Normal API-key requests do not receive this code.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-forbidden"
      },
      "document_not_found": {
        "http": {
          "status": 404,
          "type": "not_found",
          "message": "The document was not found.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": [
            "createDocument",
            "completeDocumentUpload",
            "getDocument",
            "deleteDocument"
          ]
        },
        "recovery": "unavailable-document",
        "meaning": "The document does not exist in this account or was deleted. Never treat this as a successful DELETE.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-document_not_found"
      },
      "idempotency_conflict": {
        "http": {
          "status": 409,
          "type": "conflict",
          "message": "The idempotency key was used for a different request.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": ["createDocument"]
        },
        "recovery": "idempotency",
        "meaning": "The same key was sent with a different create request body.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-idempotency_conflict"
      },
      "upload_not_complete": {
        "http": {
          "status": 409,
          "type": "conflict",
          "message": "The expected upload is not complete.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": ["completeDocumentUpload"]
        },
        "recovery": "upload-incomplete",
        "meaning": "The file is not in storage. You may upload the complete file while the upload URL is still valid.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-upload_not_complete"
      },
      "invalid_document_state": {
        "http": {
          "status": 409,
          "type": "conflict",
          "message": "The document is not in a valid state for this operation.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": []
        },
        "recovery": "document-state",
        "meaning": "The operation is not allowed for the document’s current status.",
        "note": "Reserved: the API does not currently return this code.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-invalid_document_state"
      },
      "upload_expired": {
        "http": {
          "status": 410,
          "type": "resource_gone",
          "message": "The upload reservation has expired.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": ["createDocument", "completeDocumentUpload"]
        },
        "recovery": "upload-expiry",
        "meaning": "The upload window for this document is closed. This is more than an expired signed URL.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-upload_expired"
      },
      "document_expired": {
        "http": {
          "status": 410,
          "type": "resource_gone",
          "message": "The document result is no longer available.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": [
            "createDocument",
            "completeDocumentUpload",
            "getDocument"
          ]
        },
        "recovery": "unavailable-document",
        "meaning": "The document passed its deadline: its retained result expired, or its upload window closed without a confirmed upload. It cannot be retrieved again.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-document_expired"
      },
      "document_too_large": {
        "http": {
          "status": 413,
          "type": "invalid_request",
          "message": "Maximum file size is 20 MiB.",
          "retryable": false,
          "retry_after": null,
          "field_issues": true,
          "operations": ["createDocument", "completeDocumentUpload"]
        },
        "recovery": "source-size",
        "meaning": "The declared or uploaded file is larger than 20 MiB.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-document_too_large"
      },
      "unsupported_content_type": {
        "http": {
          "status": 415,
          "type": "invalid_request",
          "message": "Supported content types are PDF, JPEG, and PNG.",
          "retryable": false,
          "retry_after": null,
          "field_issues": true,
          "operations": ["createDocument", "completeDocumentUpload"]
        },
        "recovery": "content-type",
        "meaning": "The declared content type is not supported, or the uploaded file does not match it.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-unsupported_content_type"
      },
      "upload_size_mismatch": {
        "http": {
          "status": 422,
          "type": "invalid_request",
          "message": "The uploaded object size does not match the declaration.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": ["completeDocumentUpload"]
        },
        "recovery": "invalid-input",
        "meaning": "The uploaded file size differs from file_size_bytes. Create a new document with the correct file and byte count.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-upload_size_mismatch"
      },
      "invalid_document": {
        "http": null,
        "recovery": "invalid-input",
        "meaning": "The file’s contents are not a valid PDF, JPEG, or PNG, or do not match the declared content_type.",
        "note": "Returned only as a failed document’s error, not as an HTTP error.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-invalid_document"
      },
      "usage_limit_exceeded": {
        "http": null,
        "recovery": "billing",
        "meaning": "The whole document does not fit in the remaining Trial allowance. Upgrade before trying again.",
        "note": "Returned only as a failed document’s error, not as an HTTP error.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-usage_limit_exceeded"
      },
      "usage_period_not_found": {
        "http": {
          "status": 404,
          "type": "not_found",
          "message": "The requested usage period was not found.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": ["getUsage"]
        },
        "recovery": "usage-history",
        "meaning": "The requested closed billing period does not exist for this account.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-usage_period_not_found"
      },
      "rate_limit_exceeded": {
        "http": {
          "status": 429,
          "type": "rate_limit_error",
          "message": "Too many requests.",
          "retryable": true,
          "retry_after": "required",
          "field_issues": false,
          "operations": [
            "createDocument",
            "completeDocumentUpload",
            "getDocument",
            "deleteDocument",
            "getUsage"
          ]
        },
        "recovery": "temporary-service",
        "meaning": "Too many requests. Wait at least Retry-After, then retry a limited number of times.",
        "note": "Create and upload-complete enforce rate limits today; the other operations reserve this response.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-rate_limit_exceeded"
      },
      "internal_error": {
        "http": {
          "status": 500,
          "type": "internal_error",
          "message": "An internal error occurred.",
          "retryable": false,
          "retry_after": null,
          "field_issues": false,
          "operations": [
            "createDocument",
            "completeDocumentUpload",
            "getDocument",
            "deleteDocument",
            "getUsage"
          ]
        },
        "recovery": "internal-request",
        "meaning": "Something failed on our side. An HTTP 500 alone does not mean you may retry; check retryable and keep the request ID.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-internal_error"
      },
      "service_unavailable": {
        "http": {
          "status": 503,
          "type": "service_error",
          "message": "The service is temporarily unavailable.",
          "retryable": true,
          "retry_after": "optional",
          "field_issues": false,
          "operations": ["createDocument", "completeDocumentUpload"]
        },
        "recovery": "temporary-service",
        "meaning": "The service is temporarily unavailable. Retry the same request a limited number of times when retryable is true.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-service_unavailable"
      }
    },
    "document_errors": {
      "document_processing_failed": {
        "message": "Document processing failed.",
        "retryable": false,
        "recovery": "processing-failure",
        "meaning": "Processing ended without a usable result.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-document_processing_failed"
      },
      "processing_timeout": {
        "message": "Document processing timed out.",
        "retryable": false,
        "recovery": "processing-failure",
        "meaning": "Processing took longer than its server-side time limit.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-processing_timeout"
      },
      "invalid_document": {
        "message": "The uploaded file is not a valid supported document.",
        "retryable": false,
        "recovery": "invalid-input",
        "meaning": "The file’s contents are not a valid PDF, JPEG, or PNG, or do not match the declared content_type.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-invalid_document"
      },
      "corrupt_pdf": {
        "message": "The uploaded PDF is corrupt.",
        "retryable": false,
        "recovery": "invalid-input",
        "meaning": "The PDF is corrupt. Export a valid copy and submit it as a new document.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-corrupt_pdf"
      },
      "encrypted_pdf": {
        "message": "Encrypted PDFs are not supported.",
        "retryable": false,
        "recovery": "invalid-input",
        "meaning": "The PDF is encrypted. Submit an unencrypted copy you are allowed to process.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-encrypted_pdf"
      },
      "unsupported_document_type": {
        "message": "The uploaded document is not a supported invoice.",
        "retryable": false,
        "recovery": "invalid-input",
        "meaning": "The file is not a supported invoice. Changing its content type does not change that.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-unsupported_document_type"
      },
      "multiple_invoices_detected": {
        "message": "Upload one invoice per document and try again.",
        "retryable": false,
        "recovery": "invalid-input",
        "meaning": "The file contains more than one invoice. Submit each complete invoice separately, even when invoices share a page.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-multiple_invoices_detected"
      },
      "document_page_limit_exceeded": {
        "message": "The document exceeds the 20-page limit.",
        "retryable": false,
        "recovery": "document-limits",
        "meaning": "The file has more than 20 pages.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-document_page_limit_exceeded"
      },
      "document_complexity_limit_exceeded": {
        "message": "The document exceeds safe processing limits.",
        "retryable": false,
        "recovery": "document-limits",
        "meaning": "The file or extracted invoice exceeds a safe processing limit, for example an oversized image, an overly complex or malformed PDF, or more than 500 line items or 500 tax components.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-document_complexity_limit_exceeded"
      },
      "result_too_large": {
        "message": "The normalized document result is too large.",
        "retryable": false,
        "recovery": "document-limits",
        "meaning": "The extracted result is larger than the supported size. Changing the content type or plan does not help.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-result_too_large"
      },
      "ocr_failed": {
        "message": "The document’s text and layout could not be read.",
        "retryable": false,
        "recovery": "processing-failure",
        "meaning": "Reading the document’s text and layout failed. No usable result was produced.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-ocr_failed"
      },
      "semantic_extraction_failed": {
        "message": "The invoice could not be extracted into a usable result.",
        "retryable": false,
        "recovery": "processing-failure",
        "meaning": "Extracting structured invoice data failed. No usable result was produced.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-semantic_extraction_failed"
      },
      "usage_limit_exceeded": {
        "message": "The document exceeds the remaining Trial page allowance.",
        "retryable": false,
        "recovery": "billing",
        "meaning": "The whole document does not fit in the remaining Trial allowance. Upgrade before trying again.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-usage_limit_exceeded"
      },
      "billing_required": {
        "message": "An active processing entitlement is required to process this document.",
        "retryable": false,
        "recovery": "billing",
        "meaning": "No active plan or allowance covers processing. A rejected upload-complete can be retried after you fix billing; a document that has already failed with this code cannot.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#error-billing_required"
      }
    },
    "recovery": {
      "request-fields": {
        "scenario": "Invalid request fields",
        "retry": "Not until you fix the rejected fields.",
        "identity": "error.details.issues lists the rejected fields when present. Fix them and send the create again. If the document already exists, keep its original request body and key instead of changing them.",
        "resource": "The request was rejected, not your file: this does not mean the uploaded file is corrupt. Keep any document ID you already have."
      },
      "callback-url": {
        "scenario": "Invalid callback URL",
        "retry": "Fix the callback URL, or leave it out, and send the create again.",
        "identity": "Use a public HTTPS destination with no credentials or fragment. If a document already exists for this idempotency key, do not change its request body.",
        "resource": "Only the callback was rejected; your file was not checked. Uploading the file again does not fix it."
      },
      "authentication": {
        "scenario": "Invalid API key or forbidden operation",
        "retry": "No. Fix the API key or account access first.",
        "identity": "Do not upload invoice files until the key is accepted.",
        "resource": "The rejected request created nothing. Documents you created earlier are unaffected."
      },
      "billing": {
        "scenario": "Billing required or Trial allowance exhausted",
        "retry": "After you fix billing or upgrade. Retry create with the same body and key, or retry upload-complete for the same document.",
        "identity": "After a billing error on upload-complete, do not upload the file again. If a document has already failed with this code, it cannot be resumed; trying again means a new document with a new key.",
        "resource": "Rejected before processing, so not billed. Keep the document ID. A Trial never processes part of a document to fit the remaining allowance."
      },
      "source-size": {
        "scenario": "File is too large",
        "retry": "Not with the same file. Send a file of 20 MiB or less.",
        "identity": "Declare the exact byte count. If the oversized file was already uploaded, create a new document for the smaller file; an uploaded file cannot be replaced.",
        "resource": "This is about file size only. It is not a page-limit or Trial-allowance error."
      },
      "content-type": {
        "scenario": "Unsupported or mismatched content type",
        "retry": "Use a PDF, JPEG, or PNG with the matching content_type.",
        "identity": "At create, correct content_type and send again. At upload-complete, the uploaded file cannot be replaced, so create a new document.",
        "resource": "Renaming the file or changing its content type does not turn an unsupported file into a supported one."
      },
      "invalid-input": {
        "scenario": "Invalid, corrupt, or unsupported file",
        "retry": "Not with the same file. Fix the file, or its declared size or type, first.",
        "identity": "A wrong size or type on an uploaded file needs a new document. Retrying does not fix corrupt or unsupported content, and a failed document stays failed.",
        "resource": "No usable result. Files rejected before processing are not billed. A corrected file is a new submission with its own idempotency key."
      },
      "upload-expiry": {
        "scenario": "Upload window expired",
        "retry": "No. An upload_expired response means the upload window is closed, and retrying does not reopen it.",
        "identity": "If only the signed upload URL expired and the API has not returned upload_expired, replay create with the same body and key to get a fresh URL. Start a new submission with a new key only after upload_expired. Never change the key just because a request timed out.",
        "resource": "The old upload URL no longer works, and no replacement document is created. If a create replay returns 200 awaiting_upload, call upload-complete first to check whether the file already arrived."
      },
      "upload-incomplete": {
        "scenario": "File not received",
        "retry": "Yes: upload the complete file again while the signed upload URL is still valid.",
        "identity": "The API has confirmed the file is not in storage. Send only the headers returned with the upload URL, never your API key.",
        "resource": "Use the same document and upload path; do not create a second document."
      },
      "idempotency": {
        "scenario": "Idempotency conflict",
        "retry": "Not with a changed body under the same key.",
        "identity": "Send the original create body again, or use a new key only if this is a genuinely different invoice.",
        "resource": "A document may already exist for the original request. The conflict itself is not billed."
      },
      "document-state": {
        "scenario": "Operation does not fit the document’s status",
        "retry": "Retrieve the document and choose the operation its current status allows.",
        "identity": "Keep the document ID. This code does not mean the file is missing: do not upload again or create a replacement because of it.",
        "resource": "Processing may be underway or already finished. Polling a failed document does not restart it."
      },
      "temporary-service": {
        "scenario": "Rate limit or service temporarily unavailable",
        "retry": "Yes, a limited number of times when retryable is true; treat Retry-After as a minimum delay.",
        "identity": "Retry the same request: the same create body and key, or upload-complete for the same document. A retried upload-complete is never a reason to upload the file again.",
        "resource": "A document may already exist, so keep its ID and key. A 5xx status alone does not mean you may retry; check retryable."
      },
      "internal-request": {
        "scenario": "Internal error",
        "retry": "No automatic retry when retryable is false. An HTTP 500 alone does not mean you may retry. Contact support with the request ID if needed.",
        "identity": "Keep the document ID and the exact create body and key. A failed response does not prove that nothing happened, so do not replace the document or upload again outside the steps on this page.",
        "resource": "A document or processing run may already exist. Retry the same request only when retryable is true."
      },
      "ambiguous-create": {
        "scenario": "Create timed out or returned no response",
        "retry": "Yes: send the exact create body and idempotency key again.",
        "identity": "Never change the key just because the response was lost or timed out.",
        "resource": "The document may already exist; the replay returns it."
      },
      "ambiguous-upload": {
        "scenario": "File upload outcome unknown",
        "retry": "Call upload-complete before uploading again; it tells you whether the file arrived.",
        "identity": "Upload again only after upload-complete returns upload_not_complete, and only while the signed upload URL is still valid.",
        "resource": "Use the same document; the file may already be in storage."
      },
      "ambiguous-confirmation": {
        "scenario": "upload-complete outcome unknown",
        "retry": "Retry upload-complete for the same document.",
        "identity": "Do not upload the file again and do not create a replacement document.",
        "resource": "Processing may already be queued or finished."
      },
      "sdk-wait": {
        "scenario": "SDK cancelled or stopped waiting",
        "retry": "The SDK stops waiting, but server-side work is not cancelled: processing continues.",
        "identity": "Resume with an authenticated GET using the document ID, or recover it with the same idempotency key.",
        "resource": "The document may still finish, and is billed normally if it does."
      },
      "unavailable-document": {
        "scenario": "Result expired or document not found",
        "retry": "No. Do not treat either response as a successful DELETE or a completed result.",
        "identity": "Check the document ID and the account. Save results before result_expires_at; an expired result cannot be recovered. A 404 is final.",
        "resource": "No result was returned, and no new document was created."
      },
      "usage-history": {
        "scenario": "Usage period not available",
        "retry": "Choose a closed period that still exists, or omit periods_ago for current usage.",
        "identity": "This is a usage-query error; do not resubmit or delete an invoice.",
        "resource": "The period does not exist for this account. It does not mean a document was deleted or that usage was zero."
      },
      "processing-failure": {
        "scenario": "Processing failed or timed out",
        "retry": "No. The document has reached its final failed status, and polling does not restart it. Check retryable, and contact support with the document ID if needed.",
        "identity": "Do not automatically change the key or upload again. To try again, submit a new document on purpose, with a new idempotency key.",
        "resource": "No usable result, and genuine processing failures are not billed. processing_timeout is a server-side time limit, different from the SDK giving up on polling."
      },
      "document-limits": {
        "scenario": "Page, complexity, or result-size limit",
        "retry": "Not with the same file. Check the limit and send a supported version of the complete invoice, or ask for help.",
        "identity": "The failed document is final. Do not split one invoice into parts or remove content to fit a limit. A suitable replacement is a new submission.",
        "resource": "No usable result; limit failures are not billed. Overage or a larger plan does not raise these limits."
      }
    },
    "request_issues": {
      "max_issues": 20,
      "locations": {
        "body": "The JSON request body.",
        "query": "The query parameters, by name.",
        "header": "The request headers, by lowercase name.",
        "path": "The URL path."
      },
      "codes": {
        "required": "A required field or value is missing.",
        "invalid_type": "The value has the wrong JSON type.",
        "invalid_value": "The value is not one of the allowed values.",
        "invalid_format": "The value does not have the required format.",
        "too_large": "The value is longer, larger or has more items than allowed.",
        "too_small": "The value is shorter, smaller or has fewer items than allowed.",
        "unknown_field": "The field is not accepted here.",
        "malformed": "The body or path could not be read, such as JSON that does not parse.",
        "invalid": "The value breaks another rule, which `message` describes."
      }
    },
    "callback_errors": {
      "dns_error": {
        "failure": "temporary",
        "meaning": "The callback hostname could not be resolved.",
        "fix": "Publish public DNS records for the callback hostname.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#callback-error-dns_error"
      },
      "unsafe_destination": {
        "failure": "permanent",
        "meaning": "The callback URL is not a valid destination, or its hostname resolves to no address or to a loopback, private, reserved or other non-public address.",
        "fix": "Use a hostname whose DNS answers are all public addresses, and give later documents the corrected `callback_url`.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#callback-error-unsafe_destination"
      },
      "connection_error": {
        "failure": "temporary",
        "meaning": "The connection or TLS handshake failed or was reset, or the response could not be read, for example an invalid status line.",
        "fix": "Accept HTTPS connections on port 443 and answer with a valid HTTP response.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#callback-error-connection_error"
      },
      "timeout": {
        "failure": "temporary",
        "meaning": "No response status arrived within the attempt’s time budget, which covers DNS, connection, TLS and the response.",
        "fix": "Answer with a 2xx as soon as the event arrives, and do slow work afterwards.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#callback-error-timeout"
      },
      "tls_error": {
        "failure": "permanent",
        "meaning": "The endpoint’s certificate failed verification, for example because it is self-signed, expired or not yet valid, missing intermediate certificates, or issued for another hostname.",
        "fix": "Serve a currently valid certificate for the callback hostname from a publicly trusted authority, with its full intermediate chain.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#callback-error-tls_error"
      },
      "http_error": {
        "failure": "by_status",
        "meaning": "The endpoint answered with a status other than 2xx, which `callback.last_http_status` holds. Redirects are not followed.",
        "fix": "Answer at the exact callback URL with a 2xx once the event is received.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#callback-error-http_error"
      },
      "response_too_large": {
        "failure": "temporary",
        "meaning": "The endpoint’s response headers exceeded the size limit.",
        "fix": "Keep response headers small; delivery reads only the status and `Retry-After`.",
        "docs_url": "https://temlavo.com/docs/errors-recovery#callback-error-response_too_large"
      }
    },
    "callback_delivery": {
      "window_seconds": 86400,
      "attempt_offsets_seconds": [0, 60, 300, 1800, 7200, 21600, 43200, 72000],
      "temporary_http_statuses": [
        { "from": 408, "to": 408 },
        { "from": 425, "to": 425 },
        { "from": 429, "to": 429 },
        { "from": 500, "to": 599 }
      ],
      "retry_after_http_statuses": [429, 503]
    }
  }
}
