{
  "openapi": "3.1.0",
  "info": {
    "title": "parser_backend",
    "summary": "MCA packet parsing with GPT-6 Luna (OpenRouter), verified ledgers and underwriting metrics",
    "description": "\nMCA document parsing: merchant packets in (upload or email), verified bank-statement ledgers, ISO\napplications and underwriting metrics out.\n\n**How a packet is read**\n\n1. *Intake* - files validated by content (PDF, PNG, JPEG), PDF safety-parsed, images converted to PDF;\n   email attachments extracted from every MIME part.\n2. *Split* - each PDF is split into documents (bank statement, merchant application, tax return, ...) by\n   per-page classification and statement boundaries.\n3. *Read* - a statement with a text layer is read by the **layout engine**: tables rebuilt from the text\n   layer's geometry become the ledger JSON, with no model call. Pages without a text layer, and any statement\n   whose layout read does not pass the gate, are rendered at 300 DPI and read by **GPT-6 Luna** through\n   OpenRouter with a strict JSON schema at full image resolution (Luna's answer is the OCR): one owned page per\n   call, neighbours as context, fanned out in parallel; the same answer categorizes every row. An image-read\n   ledger is accepted only when a second, independent image read agrees on every amount, date and balance.\n4. *Gate* - a ledger is **verified** only when it reconciles to the cent\n   (`opening + credits - debits = closing`), reproduces the bank's printed totals and keeps every running\n   balance chain. If it still fails after the image read it is returned as `review_required`, never as data.\n5. *Categorize* - a category and counterparty per row: revenue, MCA funding / payment, loan, NSF, overdraft,\n   returned item, transfers, payroll, taxes, ... or unknown. Image reads return them with the OCR; a\n   layout-engine ledger goes to GPT-6 Luna once as JSON (rows grouped by description, with counts, amounts and\n   dates). Deterministic rules cross-check every row.\n6. *Aggregate* - accounts and statement months (missing months flagged); MCA and loan positions decided by\n   GPT-6 Luna over the packet's possible financing streams and checked against the rows (cadence\n   cross-checks); monthly summaries, and the withhold, EBITDA and revenue math.\n7. *Packet* - the files are one submission (`result.submission_packet`): its typed documents in order, which\n   ones the decision rests on and why the others are excluded (duplicates, failed or unreconciled reads,\n   unclassified documents, another business's statement), the merchant's details with their sources,\n   month-by-month coverage, whether the statements are one unbroken history, the balance chain across\n   statements, undisclosed accounts and cross-document fraud signals.\n\nEvery Luna call is metered (prompt, cached, completion and reasoning tokens; provider-reported cost) and\nevery answer is replay-cached: a re-sent document or window costs nothing.\n\n**Integrating**\n\n* *Authentication*: `Authorization: Bearer <credential>` (or `X-API-Key`) on every `/v1` route. The credential\n  is an API key (`pk_live_...`, created with `POST /v1/api-keys`, scoped to permissions) or a WorkOS AuthKit\n  access token (a person, with the permissions of their role). Each belongs to one tenant; jobs, caches,\n  webhooks and settings are tenant-scoped. Errors are `{\"error\": {\"code\", \"message\", \"request_id\"}}`.\n* *Submit*: `POST /v1/parse` (multipart) or `POST /v1/intake/email` (raw MIME). The answer is `202` with a\n  `job_id` and `status_url`, or the finished job when `wait` seconds suffice. Send an `Idempotency-Key` to\n  make a retry return the same job.\n* *Get the result*: register a webhook once (`POST /v1/webhooks`) and receive `job.completed`,\n  `job.review_required` or `job.failed` when each job ends, signed with the endpoint's secret; then fetch\n  `GET /v1/jobs/{job_id}`. Or poll that route (`?wait=` long-polls). Every job ends in one of those three\n  states, and its event is stored with it: a job that runs past `JOB_TIMEOUT_SECONDS`, or that the service\n  stopped during too many runs, fails with its `job.failed` event.\n* *Status*: `completed` - every check passed; `review_required` - the result is usable but\n  `review_reasons` name what a person should look at; `failed` - nothing could be processed (`error`).\n",
    "version": "0.1.0"
  },
  "paths": {
    "/healthz": {
      "get": {
        "tags": [
          "health"
        ],
        "summary": "Liveness",
        "description": "200 while the process serves requests. No key.",
        "operationId": "healthz_healthz_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object",
                  "title": "Response Healthz Healthz Get"
                }
              }
            }
          }
        }
      }
    },
    "/readyz": {
      "get": {
        "tags": [
          "health"
        ],
        "summary": "Readiness: database open, Luna configured",
        "description": "200 when the job store answers and an OpenRouter key is configured, else 503 with which one is missing. No key.",
        "operationId": "readyz_readyz_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/v1/parse": {
      "post": {
        "tags": [
          "parse"
        ],
        "summary": "Parse a merchant packet (PDF / PNG / JPEG files)",
        "description": "Upload one merchant's packet: one or more files (bank statements, ISO/merchant application, other documents). The packet is one submission: the result's `submission_packet` lists its typed documents, which ones the decision rests on and why the others are excluded, the merchant's details with their sources, month-by-month coverage and the checks across statements. Optional form fields describe the packet (who sent it, the merchant it is filed under, what each file is said to be); they are recorded and never replace what the documents say. Files are validated by content (PDF, PNG, JPEG) and split into documents. A bank statement with a text layer is read by the layout engine (no model); a scanned statement, or one whose layout read does not reconcile, is read by GPT-6 Luna from 300 DPI page images, which also categorizes every row in the same call. A layout ledger is categorized by one GPT-6 Luna call over its JSON. Ledgers must pass the reconciliation gate to be returned as verified, and underwriting metrics use verified ledgers only. Returns 202 with a job id, or the finished job when `wait` seconds suffice.",
        "operationId": "parse_v1_parse_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "wait",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 3600,
              "minimum": 0,
              "description": "Seconds to wait for the result",
              "default": 0,
              "title": "Wait"
            },
            "description": "Seconds to wait for the result"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ],
              "description": "Retry-safe submission: the same key and request returns the same job; the same key with different files, order, metadata or options is refused (409)",
              "title": "Idempotency-Key"
            },
            "description": "Retry-safe submission: the same key and request returns the same job; the same key with different files, order, metadata or options is refused (409)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_parse_v1_parse_post"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobAccepted"
                }
              }
            }
          },
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobEnvelope"
                }
              }
            },
            "description": "OK"
          },
          "409": {
            "description": "Idempotency-Key reused for a different request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "The tenant's queued and running jobs are at its cap (retry later), or its monthly Luna budget is spent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/intake/email": {
      "post": {
        "tags": [
          "email"
        ],
        "summary": "Ingest one raw email (RFC 822 / MIME); its attachments become one parse job",
        "description": "Send the raw message as the request body (`Content-Type: message/rfc822`). Authenticate with an API key or token holding `jobs:write`, or as a mail provider's signed webhook for one mailbox: `X-Timestamp`, `X-Mailbox-ID`, `X-Provider-Message-ID` and `X-Signature` = hex HMAC-SHA256 of `timestamp\\nmailbox_id\\nmessage_id\\nbody` with the mailbox's inbound secret (5-minute window). Every leaf MIME part is examined, including forwarded messages; only PDF, PNG and JPEG (by content) are processed. Images under the size floor (logos, tracking pixels) and inline images are skipped. A deal is a thread: a reply that adds documents starts a job with every document the thread has sent (the earlier job's `superseded_by` names it); a message whose documents the thread already holds (a forward) returns the thread's job; a message with no document starts none (`status: ignored`). With routing on (the `email_routing` module and `EMAIL_ROUTING_API_KEY`), TypeSafe's Jev Router decides what each email is for (`email.routing` on the job, `routing` on an ignored email); one it is sure is not about a deal, outside a deal's thread, starts no job. Re-delivery of the same message returns the same job. Every message is tracked as an email (`X-Email-ID` on the response; `GET /v1/emails/{email_id}`), with its raw .eml kept; re-delivery is the same email.",
        "operationId": "intake_email_v1_intake_email_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "wait",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 3600,
              "minimum": 0,
              "default": 0,
              "title": "Wait"
            }
          },
          {
            "name": "options",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "ParseOptions as JSON",
              "title": "Options"
            },
            "description": "ParseOptions as JSON"
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Signature"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Timestamp"
            }
          },
          {
            "name": "X-Mailbox-ID",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 64
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Mailbox-Id"
            }
          },
          {
            "name": "X-Provider-Message-ID",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Provider-Message-Id"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobAccepted"
                }
              }
            }
          },
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/JobEnvelope"
                    },
                    {
                      "$ref": "#/components/schemas/EmailIgnored"
                    }
                  ],
                  "title": "Response 200 Intake Email V1 Intake Email Post"
                }
              }
            },
            "description": "OK"
          },
          "429": {
            "description": "The tenant's queued and running jobs are at its cap (retry later), or its monthly Luna budget is spent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/intake/gmail": {
      "post": {
        "tags": [
          "email"
        ],
        "summary": "Gmail's Pub/Sub push: a mailbox changed",
        "description": "The push endpoint of the Pub/Sub subscription on `GMAIL_PUBSUB_TOPIC`, authenticated by its OIDC token (`Authorization: Bearer`, audience `GMAIL_PUSH_AUDIENCE`, signed as `GMAIL_PUSH_SERVICE_ACCOUNT`). The push names the mailbox's address: it is marked for a sync and the scheduler reads every message added since its last sync. Answers 204 at once, before the sync runs.",
        "operationId": "intake_gmail_v1_intake_gmail_post",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "default": "",
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "401": {
            "description": "Not a valid push token from our subscription",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/intake/m365": {
      "post": {
        "tags": [
          "email"
        ],
        "summary": "Microsoft Graph's change notification: a Microsoft 365 mailbox received mail",
        "description": "The `notificationUrl` of each Microsoft 365 mailbox's Graph subscription. Graph first validates it (`?validationToken=`, echoed back); each notification names the subscription and carries the mailbox's secret `clientState`, which must match. The mailbox is marked for a sync and the scheduler reads its delta. Answers 202 at once.",
        "operationId": "intake_m365_v1_intake_m365_post",
        "parameters": [
          {
            "name": "validationToken",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 1024
                },
                {
                  "type": "null"
                }
              ],
              "title": "Validationtoken"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "200": {
            "description": "The subscription's validation: the token echoed as text/plain"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/intake/forward/cloudflare": {
      "post": {
        "tags": [
          "email"
        ],
        "summary": "A message to a forwarding address, from the Cloudflare Email Worker",
        "description": "The Email Worker posts each message sent to `<forward_token>@INBOUND_MAIL_DOMAIN` as raw MIME with `X-Timestamp`, `X-Envelope-To`, `X-Envelope-From` and `X-Signature` = hex HMAC-SHA256 of `timestamp\\nenvelope_to\\nenvelope_from\\nbody` with `INBOUND_FORWARD_SECRET` (5-minute window). The mailbox is the envelope recipient's; with `allowed_sender_domains` it ignores mail whose envelope sender is not in them. Answers 200 with the message's outcome (a paused mailbox's message is `refused`), 429 past the mailbox's hourly cap (`INBOUND_MAILBOX_MESSAGES_PER_HOUR`); anything other than 200 or 404 is retried by the Worker.",
        "operationId": "intake_forward_v1_intake_forward_cloudflare_post",
        "parameters": [
          {
            "name": "X-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Signature"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Timestamp"
            }
          },
          {
            "name": "X-Envelope-To",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 320,
              "default": "",
              "title": "X-Envelope-To"
            }
          },
          {
            "name": "X-Envelope-From",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "default": "",
              "title": "X-Envelope-From"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Intake Forward V1 Intake Forward Cloudflare Post"
                }
              }
            }
          },
          "401": {
            "description": "Bad signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such forwarding address: the Worker bounces it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/jobs/{job_id}": {
      "get": {
        "tags": [
          "jobs"
        ],
        "summary": "Job status and, when finished, its result",
        "description": "`queued` -> `running` -> `completed` | `review_required` | `failed`. `result` is set once the job finishes (`error` on `failed`). `wait` holds the request until the job finishes or the seconds pass (at most `MAX_WAIT_SECONDS`). The webhook events point here (`payload.result_path`). With corrections in force (`/v1/jobs/{job_id}/corrections`) the result is the corrected one: `result.corrections` summarizes what changed, and each changed transaction, position and month carries `correction` with each field's computed value next to its corrected one. `view=computed` returns the result as the pipeline produced it.",
        "operationId": "get_job_v1_jobs__job_id__get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          },
          {
            "name": "wait",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 3600,
              "minimum": 0,
              "default": 0,
              "title": "Wait"
            }
          },
          {
            "name": "view",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "corrected",
                "computed"
              ],
              "type": "string",
              "description": "corrected: with the job's corrections applied; computed: the pipeline's result, untouched",
              "default": "corrected",
              "title": "View"
            },
            "description": "corrected: with the job's corrections applied; computed: the pipeline's result, untouched"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "No such job for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      },
      "delete": {
        "tags": [
          "jobs"
        ],
        "summary": "Erase a finished job and everything derived from it",
        "description": "Erases the job's request and result, its input files, the cached reads, page atoms and index entries of its documents, the Luna answers it paid for, its metering, email thread entries and webhook events, now. Audited. This is how a merchant's deletion request is honoured: erase each of its jobs.",
        "operationId": "delete_job_v1_jobs__job_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  },
                  "title": "Response Delete Job V1 Jobs  Job Id  Delete"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "409": {
            "description": "Still queued or running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/jobs": {
      "get": {
        "tags": [
          "jobs"
        ],
        "summary": "This tenant's jobs, newest first",
        "description": "Id, status, source, timestamps, error and intake; fetch a job for its result. Filter by `status`, `source`, `since` (ISO 8601), `end_user_id` and `external_business_id`; page with `cursor` (the previous page's `next_cursor`, with the same filters). `finished_since` lists finished jobs instead, oldest finish first: the polling fallback for missed webhooks, which returns each finished job once across its pages.",
        "operationId": "list_jobs_v1_jobs_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "enum": [
                    "queued",
                    "running",
                    "completed",
                    "review_required",
                    "failed"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Status"
            }
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "enum": [
                    "upload",
                    "email"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Source"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Jobs created at or after this time",
              "title": "Since"
            },
            "description": "Jobs created at or after this time"
          },
          {
            "name": "finished_since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Only jobs that finished (completed, review_required or failed) at or after this time, oldest finish first",
              "title": "Finished Since"
            },
            "description": "Only jobs that finished (completed, review_required or failed) at or after this time, oldest finish first"
          },
          {
            "name": "end_user_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 255
                },
                {
                  "type": "null"
                }
              ],
              "description": "As sent to `POST /v1/parse`",
              "title": "End User Id"
            },
            "description": "As sent to `POST /v1/parse`"
          },
          {
            "name": "external_business_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 255
                },
                {
                  "type": "null"
                }
              ],
              "description": "As sent to `POST /v1/parse`",
              "title": "External Business Id"
            },
            "description": "As sent to `POST /v1/parse`"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 64
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobListOut"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      },
      "delete": {
        "tags": [
          "jobs"
        ],
        "summary": "Erase every finished job of one of your end users",
        "description": "Each finished job submitted with this `end_user_id` is erased exactly as `DELETE /v1/jobs/{job_id}` erases one, and audited. A job still queued or running is not erased: it is listed in `still_running`; call again once it ends. Another tenant's jobs are never touched.",
        "operationId": "erase_end_user_v1_jobs_delete",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "end_user_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "description": "As sent to `POST /v1/parse`",
              "title": "End User Id"
            },
            "description": "As sent to `POST /v1/parse`"
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobsErasedOut"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/jobs/{job_id}/files": {
      "get": {
        "tags": [
          "jobs"
        ],
        "summary": "The files a job was sent",
        "description": "Every file of the request (an email's attachments: the message itself is not kept), in order, whatever the job's status. `GET /v1/jobs/{job_id}/files/{position}` returns one's bytes.",
        "operationId": "job_files_v1_jobs__job_id__files_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/JobFileOut"
                  },
                  "title": "Response Job Files V1 Jobs  Job Id  Files Get"
                }
              }
            }
          },
          "404": {
            "description": "No such job for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/jobs/{job_id}/files/{position}": {
      "get": {
        "tags": [
          "jobs"
        ],
        "summary": "Download one of a job's original files",
        "description": "The bytes exactly as uploaded (or attached), with `Content-Disposition: attachment` and the declared content type. Erased with the job. Not streamed: each file is sealed as one authenticated piece, opened whole (at most the upload size cap).",
        "operationId": "job_file_v1_jobs__job_id__files__position__get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          },
          {
            "name": "position",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Position"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file's bytes, as sent",
            "content": {
              "application/octet-stream": {}
            }
          },
          "404": {
            "description": "No such job, or no such file",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/jobs/{job_id}/corrections": {
      "get": {
        "tags": [
          "jobs"
        ],
        "summary": "A job's corrections, with their history",
        "description": "Every correction of the job, oldest first, reverted ones included (`reverted_at`): who made it, when and why. `summary` is what the corrections in force change.",
        "operationId": "list_corrections_v1_jobs__job_id__corrections_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CorrectionsOut"
                }
              }
            }
          },
          "404": {
            "description": "No such job for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      },
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Correct a finished job: re-categorize rows, override positions, exclude months",
        "description": "Saves one or more corrections on the job, in order; they apply every time the job is read (`GET /v1/jobs/{job_id}`), and the result is recomputed from the stored ledgers with no model call. `transaction` sets a row's category (one that fits its direction) and/or counterparty, and moves the row's amount between its month's figures (from how the month counted it: `counted_as`, `mca_projected`); only a verified statement the result is computed from changes the figures. `position_override` sets a position's status, frequency, payment, funder or kind (null keeps the computed value); it changes the existing MCA burden and the withhold, not the pulls each month observed. `month_exclusion` leaves a month out of the averages, or counts one that was left out; with `account_key`, it leaves one account's figures out of the month (`months[].by_account`), merged again from the others. Per field, the latest correction in force wins; revert one to remove it. Amounts, dates, balances and rows cannot be corrected, and gates, statuses and review reasons never change. Audited; the endpoints and integrations subscribed to `job.corrected` are told.",
        "operationId": "create_corrections_v1_jobs__job_id__corrections_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CorrectionsCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CorrectionsOut"
                }
              }
            }
          },
          "404": {
            "description": "No such job for this tenant, or no such row, position, month or correction in it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The job has not finished (or has no result), or the correction is already reverted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/jobs/{job_id}/corrections/{correction_id}/revert": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Revert one correction",
        "description": "Takes the correction out of force: the value it set returns to the one before it (an earlier correction in force, else the computed value). It stays in the history with who reverted it, when and why. Audited; the endpoints and integrations subscribed to `job.corrected` are told.",
        "operationId": "revert_correction_v1_jobs__job_id__corrections__correction_id__revert_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          },
          {
            "name": "correction_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Correction Id"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/CorrectionRevert"
                  },
                  {
                    "type": "null"
                  }
                ],
                "title": "Body"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CorrectionsOut"
                }
              }
            }
          },
          "404": {
            "description": "No such job for this tenant, or no such row, position, month or correction in it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The job has not finished (or has no result), or the correction is already reverted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "tags": [
          "usage"
        ],
        "summary": "This tenant's metered usage, by day and kind",
        "description": "Daily totals (UTC) of the usage events: jobs submitted and finished by status, documents parsed, pages read (text or image), Luna tokens and cost, emails received, ignored, merged and routed, webhook deliveries and stored bytes. Totals are rolled up every 5 minutes. `group_by`: `day`, `kind` or both.",
        "operationId": "usage_v1_usage_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "From"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "To"
            }
          },
          {
            "name": "group_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40,
              "default": "day,kind",
              "title": "Group By"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Usage V1 Usage Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/quality": {
      "get": {
        "tags": [
          "usage"
        ],
        "summary": "This tenant's reading quality, by bank",
        "description": "Per institution: statements read, how many passed the gate, image reads, scans refused as unreadable, Luna labelling and second-read verification; the frequent review reasons; position evidence; how often a confident not-a-deal verdict was overruled by its deal thread; Luna cost per verified statement.",
        "operationId": "quality_v1_quality_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "From"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "To"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Quality V1 Quality Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/usage/luna": {
      "get": {
        "tags": [
          "usage"
        ],
        "summary": "Measured Luna token usage and cost, by day, task and model",
        "description": "Calls, paid and replayed calls, prompt / cached / completion / reasoning tokens and provider-reported cost over the last `days`, grouped by day, task and model; `job_id` narrows it to one job.",
        "operationId": "luna_usage_v1_usage_luna_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 365,
              "minimum": 1,
              "default": 30,
              "title": "Days"
            }
          },
          {
            "name": "job_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Luna Usage V1 Usage Luna Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/metrics": {
      "get": {
        "tags": [
          "usage"
        ],
        "summary": "In-process counters and latency histograms (platform)",
        "description": "Since the process started, across tenants: jobs submitted and finished by status, job latency, Luna calls. `platform:admin` only.",
        "operationId": "metrics_v1_metrics_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Metrics V1 Metrics Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/underwriting/withhold": {
      "post": {
        "tags": [
          "underwriting"
        ],
        "summary": "Withhold, EBITDA and capacity math over supplied months and positions",
        "description": "Recompute the underwriting block without re-parsing: e.g. after an underwriter excludes a month or edits the MCA table. Months marked `excluded` are dropped. Existing MCA monthly burden converts daily x21, weekly x4 and biweekly x2; offers use x21 / x4.2 / x2.1.",
        "operationId": "withhold_v1_underwriting_withhold_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WithholdRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnderwritingOut"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/webhooks": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "summary": "This tenant's webhook endpoints",
        "description": "Every registered endpoint, without its secret.",
        "operationId": "list_webhooks_v1_webhooks_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/WebhookOut"
                  },
                  "type": "array",
                  "title": "Response List Webhooks V1 Webhooks Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Register an endpoint for job events",
        "description": "The endpoint receives `job.completed`, `job.review_required` and `job.failed` (or the listed `topics`) for this tenant's jobs; `job.corrected` (a reviewer corrected a finished job, or reverted a correction) only when listed. The signing `secret` is returned once. Each event is a POST of `{id, tenant_id, topic, resource_type, resource_id, created_at, payload}` with `X-Parser-Event-Id` (stable across retries: dedupe on it), `X-Parser-Topic` and `X-Parser-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>`. Reply 2xx within `WEBHOOK_TIMEOUT_SECONDS`; anything else is retried after 30 s, 2 m, 10 m, 30 m, 1 h, 3 h, 6 h and 12 h.",
        "operationId": "create_webhook_v1_webhooks_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookCreated"
                }
              }
            }
          },
          "400": {
            "description": "URL refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/webhooks/{webhook_id}": {
      "delete": {
        "tags": [
          "webhooks"
        ],
        "summary": "Remove an endpoint; its pending deliveries stop",
        "description": "Pending deliveries to it are cancelled; delivered ones stay in its history until purged.",
        "operationId": "delete_webhook_v1_webhooks__webhook_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Webhook Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/webhooks/{webhook_id}/rotate-secret": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Replace the signing secret",
        "description": "Returns the new secret, shown only now. Every delivery from now on, retries included, is signed with it.",
        "operationId": "rotate_webhook_secret_v1_webhooks__webhook_id__rotate_secret_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Webhook Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookCreated"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Service Unavailable"
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/webhooks/{webhook_id}/test": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Send a signed ping to this endpoint",
        "description": "Queues a `ping` event for this endpoint only, delivered and retried like a job event; check its outcome under deliveries.",
        "operationId": "test_webhook_v1_webhooks__webhook_id__test_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Webhook Id"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookTestAccepted"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/webhooks/{webhook_id}/deliveries": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "summary": "Recent delivery attempts to this endpoint",
        "description": "Newest first: each event's status (`pending`, `delivered`, `dead`, `cancelled`), attempts, the receiver's last status code or error and the next retry.",
        "operationId": "webhook_deliveries_v1_webhooks__webhook_id__deliveries_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Webhook Id"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebhookDeliveryOut"
                  },
                  "title": "Response Webhook Deliveries V1 Webhooks  Webhook Id  Deliveries Get"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/webhooks/{webhook_id}/deliveries/{delivery_id}/resend": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Send one delivery's event again",
        "description": "Any delivery that is not still pending: `dead`, `delivered` or `cancelled`. The event is sent as it was first (the same body and `X-Parser-Event-Id`, so a receiver that already has it drops it), as a new delivery with the full retry schedule; the earlier delivery stays in the history.",
        "operationId": "resend_delivery_v1_webhooks__webhook_id__deliveries__delivery_id__resend_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Webhook Id"
            }
          },
          {
            "name": "delivery_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Delivery Id"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryOut"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "409": {
            "description": "Still pending",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/webhooks/{webhook_id}/deliveries/resend": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Send every dead delivery since a time again",
        "description": "Each event whose delivery to this endpoint died (its last attempt) at or after `since`, once, unless it has been delivered or is pending since. After an outage, pass when it began. The event is sent as it was first (the same body and `X-Parser-Event-Id`, so a receiver that already has it drops it), as a new delivery with the full retry schedule; the earlier delivery stays in the history.",
        "operationId": "resend_dead_deliveries_v1_webhooks__webhook_id__deliveries_resend_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Webhook Id"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "ISO 8601",
              "title": "Since"
            },
            "description": "ISO 8601"
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebhookDeliveryOut"
                  },
                  "title": "Response Resend Dead Deliveries V1 Webhooks  Webhook Id  Deliveries Resend Post"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission, or the tenant is suspended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/v1/me": {
      "get": {
        "tags": [
          "identity"
        ],
        "summary": "Who is calling: tenant, permissions and enabled modules",
        "operationId": "me_v1_me_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeOut"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/modules": {
      "get": {
        "tags": [
          "identity"
        ],
        "summary": "This tenant's modules, on or off",
        "operationId": "modules_v1_modules_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModulesOut"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/auth/login": {
      "get": {
        "tags": [
          "identity"
        ],
        "summary": "Sign in (people): redirects to AuthKit, which returns to /v1/auth/callback",
        "operationId": "login_v1_auth_login_get",
        "responses": {
          "302": {
            "description": "Successful Response"
          }
        }
      }
    },
    "/v1/auth/callback": {
      "get": {
        "tags": [
          "identity"
        ],
        "summary": "AuthKit returns here: the signed-in person's access and refresh tokens",
        "operationId": "callback_v1_auth_callback_get",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 1024,
              "title": "Code"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 256,
              "title": "State"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionOut"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Bad Request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/refresh": {
      "post": {
        "tags": [
          "identity"
        ],
        "summary": "A new access and refresh token for a refresh token",
        "operationId": "refresh_v1_auth_refresh_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshIn"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionOut"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tenant/settings": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "This tenant's settings",
        "operationId": "get_settings_v1_tenant_settings_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantSettingsOut"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      },
      "patch": {
        "tags": [
          "tenant"
        ],
        "summary": "Change retention or email routing",
        "description": "`retention_days` (null: keep everything) and `email_routing`. Job, spend and budget limits and the Luna route are set by the platform: sending them is refused (403).",
        "operationId": "patch_settings_v1_tenant_settings_patch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenantSettingsPatch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantSettingsOut"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/api-keys": {
      "get": {
        "tags": [
          "api-keys"
        ],
        "summary": "This tenant's API keys (never their secrets)",
        "operationId": "list_keys_v1_api_keys_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ApiKeyOut"
                  },
                  "type": "array",
                  "title": "Response List Keys V1 Api Keys Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "api-keys"
        ],
        "summary": "Create an API key; the key is returned only now",
        "description": "`scopes` default to `jobs:write jobs:read underwriting:write` (a CRM's key). A key cannot hold a permission its creator lacks.",
        "operationId": "create_key_v1_api_keys_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiKeyCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyCreated"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/api-keys/{key_id}/rotate": {
      "post": {
        "tags": [
          "api-keys"
        ],
        "summary": "Replace a key: same name and scopes, a new secret",
        "description": "The old key is revoked now, or stays valid for `overlap_seconds` (at most 7 days) so callers can switch.",
        "operationId": "rotate_key_v1_api_keys__key_id__rotate_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Key Id"
            }
          },
          {
            "name": "overlap_seconds",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 604800,
              "minimum": 0,
              "default": 0,
              "title": "Overlap Seconds"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyCreated"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/api-keys/{key_id}": {
      "delete": {
        "tags": [
          "api-keys"
        ],
        "summary": "Revoke a key at once",
        "operationId": "revoke_key_v1_api_keys__key_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Key Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/audit-log": {
      "get": {
        "tags": [
          "audit"
        ],
        "summary": "Every change made in this tenant, newest first",
        "operationId": "audit_log_v1_audit_log_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{1,19}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditLogOut"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/platform/tenants": {
      "get": {
        "tags": [
          "platform"
        ],
        "summary": "Every tenant (platform)",
        "operationId": "list_tenants_v1_platform_tenants_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/TenantOut"
                  },
                  "type": "array",
                  "title": "Response List Tenants V1 Platform Tenants Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "platform"
        ],
        "summary": "Create a tenant (platform)",
        "description": "Creates the WorkOS organization (unless `workos_org_id` names one), the tenant with default settings (every module on, data kept forever) and, with `owner_email`, the owner's WorkOS invitation.",
        "operationId": "create_tenant_v1_platform_tenants_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenantCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantCreated"
                }
              }
            }
          },
          "409": {
            "description": "Slug or organization taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "WorkOS refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/platform/usage": {
      "get": {
        "tags": [
          "platform"
        ],
        "summary": "Metered usage across tenants (platform)",
        "description": "Daily totals of every tenant's usage events; `group_by`: any of `tenant`, `day`, `kind`.",
        "operationId": "platform_usage_v1_platform_usage_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "From"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "To"
            }
          },
          {
            "name": "group_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40,
              "default": "tenant,day,kind",
              "title": "Group By"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Platform Usage V1 Platform Usage Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/platform/costs": {
      "get": {
        "tags": [
          "platform"
        ],
        "summary": "Cost and speed per tenant (platform)",
        "description": "Per tenant and/or day (UTC; `group_by`: `tenant`, `day`): Luna cost, calls (`paid_calls`: not replayed from the cache) and paid calls' latency p50/p95, by when each call was made; jobs finished (those sent to review and failed among them) and their time from submission to result p50/p95, by when each finished; `cost_per_job_usd`: the period's cost over the jobs it finished. Newest day first, then most expensive.",
        "operationId": "platform_costs_v1_platform_costs_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "From"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "To"
            }
          },
          {
            "name": "group_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40,
              "default": "tenant",
              "title": "Group By"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Platform Costs V1 Platform Costs Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/platform/health": {
      "get": {
        "tags": [
          "platform"
        ],
        "summary": "Queue, workers, mailboxes, errors (platform)",
        "description": "Queued and running jobs per tenant with the oldest queued job's age, workers holding a job, mailboxes that are failing, need reauthorization or lag behind, and the last 24 hours' failed jobs, dead webhook deliveries and dead integration runs per tenant.",
        "operationId": "platform_health_v1_platform_health_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Platform Health V1 Platform Health Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/platform/quality": {
      "get": {
        "tags": [
          "platform"
        ],
        "summary": "Reading quality across tenants (platform)",
        "description": "Per tenant and/or institution (`group_by`): statements read, gate pass rate, image reads, scans refused as unreadable, Luna labelling and second-read verification; the frequent review reasons; position evidence; Jev routing overruled; Luna cost per verified statement.",
        "operationId": "platform_quality_v1_platform_quality_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "From"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ],
              "title": "To"
            }
          },
          {
            "name": "group_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40,
              "default": "tenant,institution",
              "title": "Group By"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Platform Quality V1 Platform Quality Get"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/platform/tenants/{tenant_id}": {
      "get": {
        "tags": [
          "platform"
        ],
        "summary": "A tenant with its settings and modules (platform)",
        "operationId": "get_tenant_v1_platform_tenants__tenant_id__get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Tenant Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantDetailOut"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "platform"
        ],
        "summary": "Suspend or reactivate a tenant, change its limits, Luna route or modules (platform)",
        "description": "A suspended tenant's submissions are refused and its data kept. Changing `luna_route` or `luna_route_scans` needs a `reason`, recorded in the audit log.",
        "operationId": "patch_tenant_v1_platform_tenants__tenant_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Tenant Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenantPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantDetailOut"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "401": {
            "description": "Missing, invalid, revoked or expired API key or token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the route's permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes": {
      "get": {
        "tags": [
          "mailboxes"
        ],
        "summary": "This tenant's mailboxes",
        "operationId": "list_mailboxes_v1_mailboxes_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/MailboxOut"
                  },
                  "type": "array",
                  "title": "Response List Mailboxes V1 Mailboxes Get"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "mailboxes"
        ],
        "summary": "Connect a mailbox",
        "description": "`{kind: \"forwarding\"}`: a new address `<token>@INBOUND_MAIL_DOMAIN` to forward deals to (a Gmail filter, an Outlook rule), and an inbound secret for providers that post mail themselves. `{kind: \"gmail\", auth: \"delegation\", address}`: a mailbox in a Workspace domain that authorized the platform's service account (scope gmail.readonly); access is checked and the watch started now. `{kind: \"gmail\", auth: \"oauth\", address}`: returns `authorize_url`; the mailbox is connected when Google returns. Needs the `email_intake` module.",
        "operationId": "create_mailbox_v1_mailboxes_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MailboxCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxCreated"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/oauth/microsoft/callback": {
      "get": {
        "tags": [
          "mailboxes"
        ],
        "summary": "Microsoft returns here after a funder's admin grants the app read access",
        "operationId": "microsoft_callback_v1_oauth_microsoft_callback_get",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 4096,
              "title": "State"
            }
          },
          {
            "name": "admin_consent",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Admin Consent"
            }
          },
          {
            "name": "error",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Error"
            }
          },
          {
            "name": "error_description",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Error Description"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/oauth/google/callback": {
      "get": {
        "tags": [
          "mailboxes"
        ],
        "summary": "Google returns here after a person grants a mailbox's read access",
        "operationId": "google_callback_v1_oauth_google_callback_get",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 4096,
              "title": "State"
            }
          },
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Code"
            }
          },
          {
            "name": "error",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Error"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}": {
      "get": {
        "tags": [
          "mailboxes"
        ],
        "summary": "A mailbox",
        "operationId": "get_mailbox_v1_mailboxes__mailbox_id__get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "mailbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Mailbox Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "mailboxes"
        ],
        "summary": "Change a mailbox's label, settings, or pause it",
        "operationId": "patch_mailbox_v1_mailboxes__mailbox_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "mailbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Mailbox Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MailboxPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "mailboxes"
        ],
        "summary": "Disconnect a mailbox: stop its watch, destroy its credentials",
        "operationId": "delete_mailbox_v1_mailboxes__mailbox_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "mailbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Mailbox Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/test": {
      "post": {
        "tags": [
          "mailboxes"
        ],
        "summary": "Check a Gmail mailbox: token, label, watch",
        "operationId": "test_mailbox_v1_mailboxes__mailbox_id__test_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "mailbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Mailbox Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxTestOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/resync": {
      "post": {
        "tags": [
          "mailboxes"
        ],
        "summary": "Read a Gmail mailbox's messages again since a time (at most 7 days back)",
        "operationId": "resync_mailbox_v1_mailboxes__mailbox_id__resync_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "mailbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Mailbox Id"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "ISO 8601; at most 7 days ago",
              "title": "Since"
            },
            "description": "ISO 8601; at most 7 days ago"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "integer"
                  },
                  "title": "Response Resync Mailbox V1 Mailboxes  Mailbox Id  Resync Post"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/messages": {
      "get": {
        "tags": [
          "mailboxes"
        ],
        "summary": "What became of each message: job, merged, ignored:<reason>, refused",
        "operationId": "mailbox_messages_v1_mailboxes__mailbox_id__messages_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "mailbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Mailbox Id"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^(job|merged|ignored|refused)$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Status"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{1,19}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxMessagesOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/rotate-address": {
      "post": {
        "tags": [
          "mailboxes"
        ],
        "summary": "Give a forwarding mailbox a new address; mail to the old one bounces from now on",
        "description": "For an address that leaked (spam, a mailing list). The mailbox keeps its settings and messages. Point the Gmail filter or Outlook rule at the new `address`; Gmail mails the new address a confirmation first (`GET /v1/mailboxes/{id}/verification`).",
        "operationId": "rotate_mailbox_address_v1_mailboxes__mailbox_id__rotate_address_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "mailbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Mailbox Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/verification": {
      "get": {
        "tags": [
          "mailboxes"
        ],
        "summary": "Gmail's forwarding confirmation code and link, once it arrived",
        "operationId": "mailbox_verification_v1_mailboxes__mailbox_id__verification_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "mailbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Mailbox Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/integrations/catalog": {
      "get": {
        "tags": [
          "integrations"
        ],
        "summary": "Integration types: config JSON Schema, events, the module each needs",
        "operationId": "integration_catalog_v1_integrations_catalog_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "additionalProperties": true,
                    "type": "object"
                  },
                  "type": "array",
                  "title": "Response Integration Catalog V1 Integrations Catalog Get"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/integrations": {
      "get": {
        "tags": [
          "integrations"
        ],
        "summary": "This tenant's installed integrations",
        "operationId": "list_integrations_v1_integrations_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/IntegrationOut"
                  },
                  "type": "array",
                  "title": "Response List Integrations V1 Integrations Get"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "integrations"
        ],
        "summary": "Install an integration",
        "description": "`config` is validated against the type's schema (the catalog); `secrets` are sealed and never returned. The type's module must be on for the tenant.",
        "operationId": "install_v1_integrations_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationOut"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/integrations/{integration_id}": {
      "get": {
        "tags": [
          "integrations"
        ],
        "summary": "An installed integration (never its secrets)",
        "operationId": "get_integration_v1_integrations__integration_id__get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "integrations"
        ],
        "summary": "Rename, reconfigure, replace secrets, pause or resume",
        "operationId": "patch_integration_v1_integrations__integration_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "integrations"
        ],
        "summary": "Uninstall: its pending runs are cancelled, its secrets destroyed",
        "operationId": "uninstall_v1_integrations__integration_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/integrations/{integration_id}/connect": {
      "post": {
        "tags": [
          "integrations"
        ],
        "summary": "A new authorize_url for an OAuth integration (to reconnect it)",
        "operationId": "connect_integration_v1_integrations__integration_id__connect_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/oauth/{provider}/callback": {
      "get": {
        "tags": [
          "integrations"
        ],
        "summary": "HubSpot or Salesforce returns here after a person grants access",
        "operationId": "oauth_callback_v1_oauth__provider__callback_get",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^(hubspot|salesforce)$",
              "title": "Provider"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 4096,
              "title": "State"
            }
          },
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Code"
            }
          },
          {
            "name": "error",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Error"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/integrations/{integration_id}/test": {
      "post": {
        "tags": [
          "integrations"
        ],
        "summary": "Call the integration once (a ping), recorded as a test run",
        "operationId": "test_integration_v1_integrations__integration_id__test_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Test Integration V1 Integrations  Integration Id  Test Post"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/integrations/{integration_id}/runs": {
      "get": {
        "tags": [
          "integrations"
        ],
        "summary": "Recent deliveries and tests of this integration, newest first",
        "operationId": "integration_runs_v1_integrations__integration_id__runs_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/IntegrationRunOut"
                  },
                  "title": "Response Integration Runs V1 Integrations  Integration Id  Runs Get"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "This tenant's tracked emails, newest first",
        "description": "Every inbound email, on every path (forwarding addresses, Gmail, IMAP, Microsoft 365, `POST /v1/intake/email`), ignored and refused ones included. Filter by `mailbox_id`, `thread_id`, `tag`, `outcome` (`job`, `merged`, `ignored`, one `ignored:<reason>`, `refused`), `sender` (the From address), `since` and `job_id`; page with `cursor` (the previous page's `next_cursor`, with the same filters).",
        "operationId": "list_emails_v1_emails_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "mailbox_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 64
                },
                {
                  "type": "null"
                }
              ],
              "title": "Mailbox Id"
            }
          },
          {
            "name": "thread_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 2048
                },
                {
                  "type": "null"
                }
              ],
              "title": "Thread Id"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 64
                },
                {
                  "type": "null"
                }
              ],
              "title": "Tag"
            }
          },
          {
            "name": "outcome",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^(job|merged|ignored(:[a-z_]{1,64})?|refused)$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Outcome"
            }
          },
          {
            "name": "sender",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 320
                },
                {
                  "type": "null"
                }
              ],
              "description": "The From address, any case",
              "title": "Sender"
            },
            "description": "The From address, any case"
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Received at or after this time, ISO 8601",
              "title": "Since"
            },
            "description": "Received at or after this time, ISO 8601"
          },
          {
            "name": "job_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 64
                },
                {
                  "type": "null"
                }
              ],
              "title": "Job Id"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{1,19}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailListOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails/threads/{thread_id}/raw": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Download a thread's stored emails as one mbox",
        "description": "Every email of the thread whose raw .eml is kept, in the order they arrived, streamed. Emails kept without their bytes (refused, from a sender not allowed, or `store_raw_email` off) are left out.",
        "operationId": "thread_mbox_v1_emails_threads__thread_id__raw_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Thread Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "mboxrd: each stored .eml after a `From ` line",
            "content": {
              "application/mbox": {}
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails/threads/{thread_id}": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Every email of a thread, in the order they arrived",
        "description": "The thread id is a job's `intake.email.thread_id` or an email's `thread_id`. Each email carries its outcome and job: the full story of a deal, from the submission through every reply and forward.",
        "operationId": "get_thread_v1_emails_threads__thread_id__get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Thread Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailThreadOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "emails"
        ],
        "summary": "Erase every tracked email of a thread",
        "description": "Each email's record, raw .eml and `email.received` events, now; audited once. The thread's jobs are not touched: erase them with `DELETE /v1/jobs/{job_id}`.",
        "operationId": "delete_thread_v1_emails_threads__thread_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Thread Id"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailsErasedOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails/{email_id}": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "A tracked email",
        "operationId": "get_email_v1_emails__email_id__get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "email_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Email Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "emails"
        ],
        "summary": "Erase a tracked email",
        "description": "Its record, raw .eml and `email.received` events, now; audited. Its job is not touched (erase it with `DELETE /v1/jobs/{job_id}`, which erases the emails that fed it too).",
        "operationId": "delete_email_v1_emails__email_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "email_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Email Id"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailsErasedOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails/{email_id}/raw": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Download an email's raw .eml",
        "description": "The message exactly as received (RFC 822), as `message/rfc822` with `Content-Disposition: attachment`. 404 when its bytes are not kept: refused, from a sender not allowed, or its mailbox's `store_raw_email` off. Not streamed: sealed as one authenticated piece (at most the message size cap).",
        "operationId": "email_raw_v1_emails__email_id__raw_get",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "email_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Email Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The bytes exactly as received",
            "content": {
              "message/rfc822": {}
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails/{email_id}/tags": {
      "put": {
        "tags": [
          "emails"
        ],
        "summary": "Replace an email's tags",
        "description": "Tags are trimmed and lowercased, then 1-64 of `a-z 0-9 _ : -`; at most 20. Audited.",
        "operationId": "replace_tags_v1_emails__email_id__tags_put",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "email_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Email Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailTagsIn"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Add tags to an email",
        "description": "Tags it already has are kept once. Audited.",
        "operationId": "add_tags_v1_emails__email_id__tags_post",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "email_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Email Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailTagsIn"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/emails/{email_id}/tags/{tag}": {
      "delete": {
        "tags": [
          "emails"
        ],
        "summary": "Remove a tag from an email",
        "description": "Removing a tag it does not have changes nothing. Audited.",
        "operationId": "remove_tag_v1_emails__email_id__tags__tag__delete",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "email_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Email Id"
            }
          },
          {
            "name": "tag",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Tag"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailOut"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "description": "No such email (or thread) for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AccountCoverageOut": {
        "properties": {
          "account": {
            "type": "string",
            "title": "Account",
            "description": "Last four of the account, or 'unknown'"
          },
          "account_key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Key",
            "description": "The `accounts[].account_key` it is aggregated under"
          },
          "months": {
            "items": {
              "$ref": "#/components/schemas/CoverageMonthOut"
            },
            "type": "array",
            "title": "Months"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "account",
          "months"
        ],
        "title": "AccountCoverageOut"
      },
      "AccountSectionOut": {
        "properties": {
          "account_section_id": {
            "type": "string",
            "title": "Account Section Id"
          },
          "account_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Name"
          },
          "account_number_suffix": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Number Suffix"
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          },
          "opening_balance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Opening Balance"
          },
          "closing_balance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Closing Balance"
          },
          "credits_total": {
            "type": "string",
            "title": "Credits Total"
          },
          "debits_total": {
            "type": "string",
            "title": "Debits Total"
          },
          "transaction_count": {
            "type": "integer",
            "title": "Transaction Count"
          },
          "reconciled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Reconciled"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "account_section_id",
          "credits_total",
          "debits_total",
          "transaction_count"
        ],
        "title": "AccountSectionOut"
      },
      "ActorOut": {
        "properties": {
          "type": {
            "type": "string",
            "title": "Type",
            "description": "api_key, user or platform"
          },
          "id": {
            "type": "string",
            "title": "Id"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "type",
          "id"
        ],
        "title": "ActorOut"
      },
      "AffordabilityOverrides": {
        "properties": {
          "ebitda_margin_multiplier": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Ebitda Margin Multiplier"
          },
          "default_factor_rate": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 3.0,
                "exclusiveMinimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Default Factor Rate"
          },
          "min_avg_monthly_deposits": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Min Avg Monthly Deposits"
          },
          "min_avg_balance": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Min Avg Balance"
          },
          "max_monthly_nsfs": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Monthly Nsfs"
          },
          "max_monthly_negative_days": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Monthly Negative Days"
          },
          "min_monthly_deposit_count": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Min Monthly Deposit Count"
          },
          "max_offer_pct": {
            "anyOf": [
              {
                "type": "number",
                "exclusiveMinimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Offer Pct"
          },
          "min_offer_pct": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Min Offer Pct"
          },
          "payment_frequency": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "daily",
                  "weekly",
                  "biweekly",
                  "monthly"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Payment Frequency"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "AffordabilityOverrides",
        "description": "Overrides for the default underwriting settings."
      },
      "ApiKeyCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Name"
          },
          "scopes": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "maxItems": 20,
            "minItems": 1,
            "title": "Scopes"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "name"
        ],
        "title": "ApiKeyCreate"
      },
      "ApiKeyCreated": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "prefix": {
            "type": "string",
            "title": "Prefix"
          },
          "scopes": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Scopes"
          },
          "created_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created By"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          },
          "last_used_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Used At"
          },
          "revoked_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Revoked At"
          },
          "key": {
            "type": "string",
            "title": "Key",
            "description": "The key itself, shown only now: send it as Authorization: Bearer or X-API-Key"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "name",
          "prefix",
          "scopes",
          "created_by",
          "created_at",
          "expires_at",
          "last_used_at",
          "revoked_at",
          "key"
        ],
        "title": "ApiKeyCreated"
      },
      "ApiKeyOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "prefix": {
            "type": "string",
            "title": "Prefix"
          },
          "scopes": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Scopes"
          },
          "created_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created By"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          },
          "last_used_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Used At"
          },
          "revoked_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Revoked At"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "name",
          "prefix",
          "scopes",
          "created_by",
          "created_at",
          "expires_at",
          "last_used_at",
          "revoked_at"
        ],
        "title": "ApiKeyOut"
      },
      "ApplicationFieldsOut": {
        "properties": {
          "legal_business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Legal Business Name",
            "description": "The business's legal name"
          },
          "dba": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Dba",
            "description": "Doing-business-as (trade) name"
          },
          "entity_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Entity Type",
            "description": "LLC, corporation, sole proprietorship, ..."
          },
          "ein": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ein",
            "description": "Federal tax id (EIN); a 9-digit EIN is written `12-3456789`"
          },
          "business_start_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Start Date",
            "description": "When the business started (`YYYY-MM-DD` where the date is clear)"
          },
          "state_of_incorporation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "State Of Incorporation",
            "description": "Two-letter state code where read by the text readers"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry",
            "description": "Industry or business description"
          },
          "naics": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Naics",
            "description": "NAICS code"
          },
          "business_phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Phone",
            "description": "The business's phone number"
          },
          "business_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Email",
            "description": "The business's email address"
          },
          "website": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Website",
            "description": "The business's website"
          },
          "address_line_1": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Address Line 1",
            "description": "Business street address"
          },
          "address_line_2": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Address Line 2",
            "description": "Suite, unit or floor"
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "City",
            "description": "Business city"
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "State",
            "description": "Business state (two-letter code where read by the text readers)"
          },
          "zip": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Zip",
            "description": "Business ZIP code"
          },
          "requested_amount": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Requested Amount",
            "description": "Funding amount requested, USD"
          },
          "use_of_funds": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Use Of Funds",
            "description": "What the funds are for"
          },
          "monthly_revenue": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Monthly Revenue",
            "description": "Monthly revenue the applicant states, USD"
          },
          "gross_annual_revenue": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gross Annual Revenue",
            "description": "Annual gross revenue the applicant states, USD"
          },
          "existing_advances_disclosed": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Existing Advances Disclosed",
            "description": "Existing advances or loans the applicant lists"
          },
          "broker_company_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Broker Company Name",
            "description": "The ISO or broker named on the form"
          },
          "home_phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Home Phone",
            "description": "The principal owner's home phone, where the form prints one"
          },
          "signed": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signed",
            "description": "Whether the application is signed: true/false from GPT-6 Luna (which sees the signature), else the form's own text (`true`, `Yes`, `No`, ...) when only the text readers found it"
          },
          "signed_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signed Date",
            "description": "When it was signed (`YYYY-MM-DD` where the date is clear)"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "title": "ApplicationFieldsOut",
        "description": "The application's business fields, as printed (dates, amounts and phone numbers are strings in the form's\nown format; amounts without commas). A field the application does not carry is absent. Each value's reader is\nin `field_sources`."
      },
      "ApplicationOut": {
        "properties": {
          "document_id": {
            "type": "string",
            "title": "Document Id"
          },
          "source_file": {
            "type": "string",
            "title": "Source File"
          },
          "content_sha256": {
            "type": "string",
            "title": "Content Sha256"
          },
          "packet_pages": {
            "items": {
              "type": "integer"
            },
            "type": "array",
            "title": "Packet Pages"
          },
          "document_type": {
            "type": "string",
            "title": "Document Type"
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "review_required",
              "failed"
            ],
            "title": "Status"
          },
          "review_reasons": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Review Reasons"
          },
          "fields": {
            "$ref": "#/components/schemas/ApplicationFieldsOut"
          },
          "owners": {
            "items": {
              "$ref": "#/components/schemas/ApplicationOwnerOut"
            },
            "type": "array",
            "title": "Owners"
          },
          "field_sources": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Field Sources",
            "description": "acroform | luna | text_regex | layout"
          },
          "cache_hit": {
            "type": "boolean",
            "title": "Cache Hit",
            "default": false
          },
          "usage": {
            "$ref": "#/components/schemas/UsageSummary"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "document_id",
          "source_file",
          "content_sha256",
          "packet_pages",
          "document_type",
          "status"
        ],
        "title": "ApplicationOut"
      },
      "ApplicationOwnerOut": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name",
            "description": "Full name"
          },
          "title": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Title",
            "description": "Title or role"
          },
          "ownership_pct": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ownership Pct",
            "description": "Ownership share, percent: a number from GPT-6 Luna, else as printed"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email",
            "description": "Email address"
          },
          "mobile_phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mobile Phone",
            "description": "Mobile phone"
          },
          "home_address": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Home Address",
            "description": "Home street address"
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "City",
            "description": "Home city"
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "State",
            "description": "Home state"
          },
          "zip": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Zip",
            "description": "Home ZIP code"
          },
          "date_of_birth": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Date Of Birth",
            "description": "Date of birth (`YYYY-MM-DD` where the date is clear)"
          },
          "ssn_last4": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ssn Last4",
            "description": "The SSN's last four digits; the full number is never read into a result"
          },
          "credit_score": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Credit Score",
            "description": "Credit score: a number from GPT-6 Luna, else as printed"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "title": "ApplicationOwnerOut",
        "description": "One owner or guarantor, as printed. The first owner merges every reader; the others are GPT-6 Luna's.\nBy design an SSN is read as its last four digits only: no full SSN is ever in a result (the\ndocuments themselves are kept as sent until the job is erased)."
      },
      "AttemptOut": {
        "properties": {
          "attempt": {
            "type": "integer",
            "title": "Attempt"
          },
          "read": {
            "type": "string",
            "enum": [
              "layout",
              "image_read",
              "image_reread",
              "image_verification"
            ],
            "title": "Read",
            "description": "layout: the text layer through the layout engine, deterministic and free; image_read: every page as an image read by GPT-6 Luna (after a layout read that did not pass, with its diagnosis); image_reread: one more image read of a ledger that did not reconcile, told what failed; image_verification: an independent second image read that must agree on every amount, date and balance before an image-read ledger is accepted"
          },
          "reconciled": {
            "type": "boolean",
            "title": "Reconciled"
          },
          "gate_status": {
            "type": "string",
            "enum": [
              "accepted",
              "review_required",
              "failed"
            ],
            "title": "Gate Status"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason"
          },
          "windows": {
            "type": "integer",
            "title": "Windows"
          },
          "cost_usd": {
            "type": "string",
            "title": "Cost Usd"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "attempt",
          "read",
          "reconciled",
          "gate_status",
          "windows",
          "cost_usd"
        ],
        "title": "AttemptOut"
      },
      "AuditEntryOut": {
        "properties": {
          "id": {
            "type": "integer",
            "title": "Id"
          },
          "ts": {
            "type": "string",
            "format": "date-time",
            "title": "Ts"
          },
          "actor_type": {
            "type": "string",
            "title": "Actor Type"
          },
          "actor_id": {
            "type": "string",
            "title": "Actor Id"
          },
          "action": {
            "type": "string",
            "title": "Action"
          },
          "target_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Target Type"
          },
          "target_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Target Id"
          },
          "ip": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ip"
          },
          "request_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Request Id"
          },
          "detail": {
            "additionalProperties": true,
            "type": "object",
            "title": "Detail"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "ts",
          "actor_type",
          "actor_id",
          "action",
          "target_type",
          "target_id",
          "ip",
          "request_id",
          "detail"
        ],
        "title": "AuditEntryOut"
      },
      "AuditLogOut": {
        "properties": {
          "entries": {
            "items": {
              "$ref": "#/components/schemas/AuditEntryOut"
            },
            "type": "array",
            "title": "Entries"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor",
            "description": "Pass as ?cursor= for older entries; null at the end"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "entries",
          "next_cursor"
        ],
        "title": "AuditLogOut"
      },
      "Body_parse_v1_parse_post": {
        "properties": {
          "files": {
            "items": {
              "type": "string",
              "contentMediaType": "application/octet-stream"
            },
            "type": "array",
            "title": "Files",
            "description": "Documents of one merchant"
          },
          "options": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Options",
            "description": "ParseOptions as JSON"
          },
          "document_types": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Document Types",
            "description": "One declared type per file, in upload order: bank_statement.business, bank_statement.personal, credit_card_statement, tax_return.1040, tax_return.1120s, tax_return.1065, tax_return.w2, tax_return.1099_nec, application.mca, application.sba, agreement.mca, voided_check, drivers_license, coi.acord_25, coi.acord_27, unknown. Recorded, never used in place of the classifier"
          },
          "broker_email": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 320
              },
              {
                "type": "null"
              }
            ],
            "title": "Broker Email",
            "description": "The ISO / broker that sent it"
          },
          "contact_email": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 320
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Email",
            "description": "The merchant's contact"
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name",
            "description": "The merchant's legal name"
          },
          "business_ein": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 32
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Ein",
            "description": "The merchant's EIN (9 digits)"
          },
          "external_business_id": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ],
            "title": "External Business Id",
            "description": "Your id for the merchant: links its submissions"
          },
          "end_user_id": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ],
            "title": "End User Id",
            "description": "Your merchant record id, echoed"
          },
          "requested_advance_amount": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Requested Advance Amount",
            "description": "Amount requested, USD"
          }
        },
        "type": "object",
        "required": [
          "files"
        ],
        "title": "Body_parse_v1_parse_post"
      },
      "BusinessIdentityOut": {
        "properties": {
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "business_ein": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Ein"
          },
          "external_business_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "External Business Id"
          },
          "identity_source": {
            "type": "string",
            "enum": [
              "declared_ein",
              "declared_external_id",
              "application_ein",
              "statements",
              "declared_business_name",
              "none"
            ],
            "title": "Identity Source",
            "description": "What identifies the merchant across submissions, strongest first: an EIN the caller declared, the caller's own merchant id, the EIN on the application, the packet's statements, the declared name"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "identity_source"
        ],
        "title": "BusinessIdentityOut",
        "description": "The merchant the caller filed the packet under, as sent."
      },
      "CashAdvanceIn": {
        "properties": {
          "funder": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Funder"
          },
          "frequency": {
            "type": "string",
            "enum": [
              "daily",
              "weekly",
              "biweekly"
            ],
            "title": "Frequency"
          },
          "payment_amount": {
            "type": "number",
            "exclusiveMinimum": 0.0,
            "title": "Payment Amount"
          },
          "last_payment_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Payment Date"
          },
          "active": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Active",
            "description": "Explicit Active flag; honored when set. Unset: active when last_payment_date is within the 14-day window (28 for biweekly), or when no last_payment_date is given"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "frequency",
          "payment_amount"
        ],
        "title": "CashAdvanceIn",
        "description": "An existing MCA position (a cash-advance row)."
      },
      "ChangedValue": {
        "properties": {
          "computed": {
            "title": "Computed",
            "description": "The machine's value"
          },
          "corrected": {
            "title": "Corrected",
            "description": "The value with the job's corrections applied"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "computed",
          "corrected"
        ],
        "title": "ChangedValue"
      },
      "CompanyProfileOut": {
        "properties": {
          "legal_business_name": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `legal_business_name`; statements' holder"
          },
          "doing_business_as": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `dba`; statements' holder"
          },
          "business_start_date": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `business_start_date`"
          },
          "federal_tax_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Declared `business_ein`; application `ein`"
          },
          "entity_type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `entity_type`"
          },
          "state_of_incorporation": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `state_of_incorporation`"
          },
          "company_phone": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `business_phone`"
          },
          "company_website": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `website`"
          },
          "company_email": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `business_email`"
          },
          "industry_type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `industry`"
          },
          "naics": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `naics`"
          },
          "annual_revenue": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `gross_annual_revenue`"
          },
          "monthly_revenue": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `monthly_revenue`"
          },
          "amount_requested": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Declared `requested_advance_amount`; application `requested_amount`"
          },
          "loan_purpose": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `use_of_funds`"
          },
          "address_line_1": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `address_line_1`"
          },
          "address_line_2": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `address_line_2`"
          },
          "city": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `city`"
          },
          "state": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `state`"
          },
          "zip_code": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `zip`"
          },
          "owner_name": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "First owner's `name`"
          },
          "ownership_percentage": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "First owner's `ownership_pct`"
          },
          "mobile_phone": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "First owner's `mobile_phone`"
          },
          "owner_email": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "First owner's `email`"
          },
          "ssn_last4": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "First owner's `ssn_last4`: never more than the last four digits"
          },
          "date_of_birth": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "First owner's `date_of_birth`"
          },
          "credit_score": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "First owner's `credit_score`"
          },
          "has_signed": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `signed`, as `true` / `false` or the form's text"
          },
          "signed_date": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProfileFieldOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Application `signed_date`"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "title": "CompanyProfileOut",
        "description": "Every key is present, its `value` null when no source has it. Sources: `request` (the declared business\nname, EIN and requested amount), each `iso_application` (the application field named), each `bank_statement`\n(the account holder, for the two business names)."
      },
      "CorrectionOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "change": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TransactionCorrection"
              },
              {
                "$ref": "#/components/schemas/PositionOverride-Output"
              },
              {
                "$ref": "#/components/schemas/MonthExclusion"
              }
            ],
            "title": "Change",
            "discriminator": {
              "propertyName": "type",
              "mapping": {
                "month_exclusion": "#/components/schemas/MonthExclusion",
                "position_override": "#/components/schemas/PositionOverride-Output",
                "transaction": "#/components/schemas/TransactionCorrection"
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "created_by": {
            "$ref": "#/components/schemas/ActorOut"
          },
          "reverted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Reverted At",
            "description": "Set once reverted: no longer in force"
          },
          "reverted_by": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ActorOut"
              },
              {
                "type": "null"
              }
            ]
          },
          "revert_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Revert Reason"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "change",
          "created_at",
          "created_by"
        ],
        "title": "CorrectionOut"
      },
      "CorrectionProvenance": {
        "properties": {
          "correction_ids": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Correction Ids",
            "description": "The corrections in force on this item, oldest first"
          },
          "changes": {
            "additionalProperties": {
              "$ref": "#/components/schemas/ChangedValue"
            },
            "type": "object",
            "title": "Changes"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "correction_ids"
        ],
        "title": "CorrectionProvenance",
        "description": "What a reviewer's corrections changed on this item: each field's computed value next to its corrected one."
      },
      "CorrectionRevert": {
        "properties": {
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "CorrectionRevert"
      },
      "CorrectionsCreate": {
        "properties": {
          "corrections": {
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/TransactionCorrection"
                },
                {
                  "$ref": "#/components/schemas/PositionOverride-Input"
                },
                {
                  "$ref": "#/components/schemas/MonthExclusion"
                }
              ],
              "discriminator": {
                "propertyName": "type",
                "mapping": {
                  "month_exclusion": "#/components/schemas/MonthExclusion",
                  "position_override": "#/components/schemas/PositionOverride-Input",
                  "transaction": "#/components/schemas/TransactionCorrection"
                }
              }
            },
            "type": "array",
            "maxItems": 100,
            "minItems": 1,
            "title": "Corrections",
            "description": "Applied in order"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "corrections"
        ],
        "title": "CorrectionsCreate"
      },
      "CorrectionsOut": {
        "properties": {
          "job_id": {
            "type": "string",
            "title": "Job Id"
          },
          "corrections": {
            "items": {
              "$ref": "#/components/schemas/CorrectionOut"
            },
            "type": "array",
            "title": "Corrections"
          },
          "summary": {
            "$ref": "#/components/schemas/CorrectionsSummary"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "job_id",
          "corrections",
          "summary"
        ],
        "title": "CorrectionsOut"
      },
      "CorrectionsSummary": {
        "properties": {
          "active": {
            "type": "integer",
            "title": "Active",
            "description": "Corrections in force"
          },
          "reverted": {
            "type": "integer",
            "title": "Reverted"
          },
          "last_changed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Changed At",
            "description": "The latest correction or revert"
          },
          "correction_ids": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Correction Ids",
            "description": "The corrections in force, oldest first"
          },
          "transactions": {
            "items": {
              "$ref": "#/components/schemas/RowRef"
            },
            "type": "array",
            "title": "Transactions",
            "description": "Rows that carry a correction"
          },
          "positions": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Positions",
            "description": "Keys of positions that carry a correction"
          },
          "months": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Months",
            "description": "Months whose figures or inclusion changed"
          },
          "underwriting": {
            "additionalProperties": {
              "$ref": "#/components/schemas/ChangedValue"
            },
            "type": "object",
            "title": "Underwriting",
            "description": "Each underwriting field that changed, computed next to corrected"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "active",
          "reverted"
        ],
        "title": "CorrectionsSummary",
        "description": "What the job's corrections in force change. Gates, statuses and review reasons never change."
      },
      "CoverageMonthOut": {
        "properties": {
          "month": {
            "type": "string",
            "title": "Month"
          },
          "status": {
            "type": "string",
            "enum": [
              "reconciled",
              "unreconciled",
              "missing_data"
            ],
            "title": "Status"
          },
          "transaction_count": {
            "type": "integer",
            "title": "Transaction Count"
          },
          "document_ids": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Document Ids"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "month",
          "status",
          "transaction_count"
        ],
        "title": "CoverageMonthOut"
      },
      "CrossStatementOut": {
        "properties": {
          "balance_chain": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Balance Chain",
            "description": "Each account's closing balance against the next statement's opening balance"
          },
          "missing_account_join": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Missing Account Join",
            "description": "Accounts the merchant's own transfers mention, matched against the submitted ones: an undisclosed account can divert revenue"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "CrossStatementOut",
        "description": "Checks that need every statement of the packet at once."
      },
      "DocumentQualityAssessment": {
        "properties": {
          "readiness_score": {
            "type": "number",
            "maximum": 1.0,
            "minimum": 0.0,
            "title": "Readiness Score"
          },
          "quality_score": {
            "type": "number",
            "maximum": 1.0,
            "minimum": 0.0,
            "title": "Quality Score"
          },
          "quality_tier": {
            "$ref": "#/components/schemas/QualityTier"
          },
          "assessed_pages": {
            "type": "integer",
            "minimum": 0.0,
            "title": "Assessed Pages"
          },
          "reupload_required": {
            "type": "boolean",
            "title": "Reupload Required",
            "default": false
          },
          "page_assessments": {
            "items": {
              "$ref": "#/components/schemas/PageQualityAssessment"
            },
            "type": "array",
            "title": "Page Assessments"
          },
          "issues": {
            "items": {
              "$ref": "#/components/schemas/ImageQualityIssue"
            },
            "type": "array",
            "title": "Issues"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "readiness_score",
          "quality_score",
          "quality_tier",
          "assessed_pages"
        ],
        "title": "DocumentQualityAssessment"
      },
      "EarlierSubmissionOut": {
        "properties": {
          "job_id": {
            "type": "string",
            "title": "Job Id"
          },
          "document_id": {
            "type": "string",
            "title": "Document Id"
          },
          "relation": {
            "type": "string",
            "enum": [
              "same_statement",
              "same_statement_different_read",
              "replaced_unverified_read"
            ],
            "title": "Relation",
            "description": "same_statement: this read matches the earlier one row for row; same_statement_different_read: this read reconciled too but its rows differ, and the earlier read stands (flagged for review); replaced_unverified_read: this read did not pass the gate and the earlier verified read of the statement stands"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "job_id",
          "document_id",
          "relation"
        ],
        "title": "EarlierSubmissionOut",
        "description": "The same statement in an earlier job of the tenant (another ISO's packet, a re-send)."
      },
      "EmailAttachmentOut": {
        "properties": {
          "filename": {
            "type": "string",
            "title": "Filename"
          },
          "content_type": {
            "type": "string",
            "title": "Content Type",
            "description": "As the email declared it"
          },
          "size_bytes": {
            "type": "integer",
            "title": "Size Bytes"
          },
          "sha256": {
            "type": "string",
            "title": "Sha256"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "filename",
          "content_type",
          "size_bytes",
          "sha256"
        ],
        "title": "EmailAttachmentOut"
      },
      "EmailIgnored": {
        "properties": {
          "status": {
            "type": "string",
            "const": "ignored",
            "title": "Status",
            "default": "ignored"
          },
          "reason": {
            "type": "string",
            "enum": [
              "no_processable_attachments",
              "not_deal_related",
              "auto_parse_off",
              "forwarding_confirmation"
            ],
            "title": "Reason",
            "description": "no_processable_attachments: no PDF, PNG or JPEG document in it (a reply, a question); not_deal_related: the router is at least the tenant's skip_confidence sure it is not about a deal, and its thread holds none; auto_parse_off: the mailbox records mail without parsing it; forwarding_confirmation: Gmail's code for confirming a forwarding address (see the mailbox's verification)"
          },
          "job_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Job Id",
            "description": "The thread's current job, if it has one"
          },
          "thread_id": {
            "type": "string",
            "title": "Thread Id"
          },
          "provider_message_id": {
            "type": "string",
            "title": "Provider Message Id"
          },
          "routing": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EmailRoutingOut"
              },
              {
                "type": "null"
              }
            ]
          },
          "email_id": {
            "type": "string",
            "title": "Email Id",
            "description": "The tracked email: `GET /v1/emails/{email_id}`"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "reason",
          "thread_id",
          "provider_message_id",
          "email_id"
        ],
        "title": "EmailIgnored",
        "description": "An email that started no job."
      },
      "EmailListOut": {
        "properties": {
          "emails": {
            "items": {
              "$ref": "#/components/schemas/EmailOut"
            },
            "type": "array",
            "title": "Emails"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor",
            "description": "Pass as `cursor` (with the same filters) for the next page; null on the last page"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "emails",
          "next_cursor"
        ],
        "title": "EmailListOut"
      },
      "EmailOut": {
        "properties": {
          "email_id": {
            "type": "string",
            "title": "Email Id",
            "description": "Stable: a redelivery of the same message is the same email"
          },
          "thread_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Thread Id",
            "description": "Its thread: the mailbox and the thread's root Message-ID"
          },
          "mailbox_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mailbox Id",
            "description": "Null when posted to `/v1/intake/email` with an API key"
          },
          "provider_message_id": {
            "type": "string",
            "title": "Provider Message Id",
            "description": "Its Message-ID, or the provider's id for it"
          },
          "message_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message Id",
            "description": "The Message-ID header, without its angle brackets"
          },
          "in_reply_to": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "In Reply To"
          },
          "references": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "References",
            "description": "The References header's message ids, oldest first"
          },
          "from": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "From"
          },
          "to": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "To"
          },
          "cc": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Cc"
          },
          "subject": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Subject"
          },
          "received_at": {
            "type": "string",
            "format": "date-time",
            "title": "Received At"
          },
          "size_bytes": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Size Bytes",
            "description": "The raw message's size"
          },
          "attachments": {
            "items": {
              "$ref": "#/components/schemas/EmailAttachmentOut"
            },
            "type": "array",
            "title": "Attachments",
            "description": "Every attachment, processable or not"
          },
          "outcome": {
            "type": "string",
            "title": "Outcome",
            "description": "job, merged, ignored:<reason> or refused"
          },
          "job_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Job Id",
            "description": "The job it started or belongs to: its thread's job when it was handled"
          },
          "routing": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EmailRoutingOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "The router's verdict; null when not routed"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags"
          },
          "raw_stored": {
            "type": "boolean",
            "title": "Raw Stored",
            "description": "Its raw .eml is kept: `GET /v1/emails/{email_id}/raw`"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "email_id",
          "thread_id",
          "mailbox_id",
          "provider_message_id",
          "message_id",
          "in_reply_to",
          "references",
          "from",
          "to",
          "cc",
          "subject",
          "received_at",
          "size_bytes",
          "attachments",
          "outcome",
          "job_id",
          "routing",
          "tags",
          "raw_stored"
        ],
        "title": "EmailOut",
        "description": "A tracked inbound email: its envelope and what became of it, never its body."
      },
      "EmailRoutingConfig": {
        "properties": {
          "model": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Model",
            "default": "typesafe/jev-router"
          },
          "skip_confidence": {
            "type": "number",
            "maximum": 1.0,
            "minimum": 0.5,
            "title": "Skip Confidence",
            "default": 0.9
          },
          "internal_domains": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "maxItems": 50,
            "title": "Internal Domains"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "EmailRoutingConfig",
        "description": "How Jev routing treats this tenant's email; the ``email_routing`` module turns it on or off."
      },
      "EmailRoutingOut": {
        "properties": {
          "intent": {
            "type": "string",
            "enum": [
              "new_submission",
              "more_documents",
              "question_or_update",
              "internal_note",
              "contract_or_funding",
              "not_deal_related"
            ],
            "title": "Intent"
          },
          "confidence": {
            "type": "number",
            "title": "Confidence",
            "description": "The model's own confidence in that intent, 0-1 (not a measured probability)"
          },
          "model": {
            "type": "string",
            "title": "Model",
            "description": "The router asked (typesafe/jev-router)"
          },
          "served_model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Served Model",
            "description": "The model the router chose"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "intent",
          "confidence",
          "model"
        ],
        "title": "EmailRoutingOut",
        "description": "What TypeSafe's Jev Router decided an email is for (``EMAIL_ROUTING_API_KEY``)."
      },
      "EmailTagsIn": {
        "properties": {
          "tags": {
            "items": {
              "type": "string",
              "description": "Trimmed and lowercased, then 1-64 of a-z 0-9 _ : -",
              "examples": [
                "client:acme"
              ]
            },
            "type": "array",
            "maxItems": 20,
            "title": "Tags",
            "description": "Each trimmed and lowercased, then 1-64 of `a-z 0-9 _ : -`; at most 20 on an email"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "tags"
        ],
        "title": "EmailTagsIn"
      },
      "EmailThreadOut": {
        "properties": {
          "thread_id": {
            "type": "string",
            "title": "Thread Id"
          },
          "emails": {
            "items": {
              "$ref": "#/components/schemas/EmailOut"
            },
            "type": "array",
            "title": "Emails",
            "description": "In the order they arrived"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "thread_id",
          "emails"
        ],
        "title": "EmailThreadOut"
      },
      "EmailsErasedOut": {
        "properties": {
          "erased": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Erased",
            "description": "The email ids erased now"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "erased"
        ],
        "title": "EmailsErasedOut"
      },
      "ErrorBody": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "description": "unauthenticated, forbidden, not_found, conflict, limit_reached, ..."
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "request_id": {
            "type": "string",
            "title": "Request Id",
            "description": "Also in the X-Request-ID response header"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "code",
          "message",
          "request_id"
        ],
        "title": "ErrorBody"
      },
      "ErrorResponse": {
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorBody"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "error"
        ],
        "title": "ErrorResponse"
      },
      "FileDeclarationOut": {
        "properties": {
          "file_index": {
            "type": "integer",
            "minimum": 0.0,
            "title": "File Index",
            "description": "Position of the file in the upload, from 0"
          },
          "filename": {
            "type": "string",
            "title": "Filename"
          },
          "declared_document_type": {
            "type": "string",
            "title": "Declared Document Type"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "file_index",
          "filename",
          "declared_document_type"
        ],
        "title": "FileDeclarationOut",
        "description": "What the caller said a file is. Recorded for review; never used in place of the classifier."
      },
      "FileOut": {
        "properties": {
          "filename": {
            "type": "string",
            "title": "Filename"
          },
          "content_sha256": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content Sha256"
          },
          "status": {
            "type": "string",
            "enum": [
              "processed",
              "rejected",
              "skipped",
              "duplicate",
              "failed"
            ],
            "title": "Status"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason"
          },
          "page_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Page Count"
          },
          "segments": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Segments",
            "description": "Typed documents found in this file"
          },
          "page_classification": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Page Classification",
            "description": "Per page: read mode, document type, classifier, boundary"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "filename",
          "status"
        ],
        "title": "FileOut"
      },
      "FraudReasonOut": {
        "properties": {
          "signal": {
            "type": "string",
            "title": "Signal",
            "description": "identity_mismatch (the application's business or owner against the statements' holders or an ID), account_number_mismatch (a voided check against the statement), declared_revenue_overstatement (the application's monthly revenue far above the statements'), cross_statement_balance_chain_break (a statement's closing balance is not the next one's opening), duplicate_period_divergent_content (one account and period sent twice with different rows), cross_statement_amount_divergence (one transaction, two amounts), duplicate_account_under_distinct_labels (one account sent twice under two labels)"
          },
          "severity": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high",
              "critical"
            ],
            "title": "Severity",
            "description": "declared_revenue_overstatement is medium; a balance-chain break both of whose statements reconcile is critical; every other signal is high"
          },
          "evidence": {
            "type": "string",
            "title": "Evidence",
            "description": "What was compared, with the values, in one sentence"
          },
          "description": {
            "type": "string",
            "title": "Description",
            "description": "What the signal means, the same text for every packet"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "required": [
          "signal",
          "severity",
          "evidence",
          "description"
        ],
        "title": "FraudReasonOut"
      },
      "GateOut": {
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "review_required",
              "failed"
            ],
            "title": "Status"
          },
          "reconciled": {
            "type": "boolean",
            "title": "Reconciled"
          },
          "confidence": {
            "type": "number",
            "title": "Confidence"
          },
          "reasons": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Reasons"
          },
          "reconciliation_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Reconciliation Reason"
          },
          "reconciliation_evidence": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Reconciliation Evidence"
          },
          "delta": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Delta"
          },
          "integrity_signals": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Integrity Signals"
          },
          "priority": {
            "type": "string",
            "title": "Priority",
            "default": "low"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "status",
          "reconciled",
          "confidence"
        ],
        "title": "GateOut"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "ImageQualityIssue": {
        "properties": {
          "code": {
            "type": "string",
            "minLength": 1,
            "title": "Code"
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "title": "Message"
          },
          "severity": {
            "type": "string",
            "enum": [
              "info",
              "warning",
              "blocking"
            ],
            "title": "Severity",
            "default": "warning"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "title": "ImageQualityIssue"
      },
      "ImapAccess": {
        "properties": {
          "host": {
            "type": "string",
            "maxLength": 255,
            "minLength": 1,
            "title": "Host"
          },
          "port": {
            "type": "integer",
            "maximum": 65535.0,
            "minimum": 1.0,
            "title": "Port",
            "default": 993
          },
          "username": {
            "type": "string",
            "maxLength": 320,
            "minLength": 1,
            "title": "Username"
          },
          "password": {
            "type": "string",
            "maxLength": 1000,
            "minLength": 1,
            "title": "Password",
            "description": "Write-only; sealed under the master key"
          },
          "ssl": {
            "type": "boolean",
            "title": "Ssl",
            "default": true
          },
          "folder": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Folder",
            "default": "INBOX"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "host",
          "username",
          "password"
        ],
        "title": "ImapAccess"
      },
      "IntegrationCreate": {
        "properties": {
          "type": {
            "type": "string",
            "title": "Type",
            "description": "A catalog type, e.g. crm_push_generic"
          },
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Name"
          },
          "config": {
            "additionalProperties": true,
            "type": "object",
            "title": "Config"
          },
          "secrets": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Secrets",
            "description": "Write-only: never returned"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "type",
          "name"
        ],
        "title": "IntegrationCreate"
      },
      "IntegrationOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "type": {
            "type": "string",
            "title": "Type"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "config": {
            "additionalProperties": true,
            "type": "object",
            "title": "Config"
          },
          "events": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Events"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "has_secrets": {
            "type": "boolean",
            "title": "Has Secrets"
          },
          "last_ok_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Ok At"
          },
          "last_error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Error"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "authorize_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Authorize Url",
            "description": "OAuth types: open it to connect; shown on install and on /connect"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "type",
          "name",
          "config",
          "events",
          "status",
          "has_secrets",
          "last_ok_at",
          "last_error",
          "created_at"
        ],
        "title": "IntegrationOut"
      },
      "IntegrationPatch": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "config": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Config"
          },
          "secrets": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Secrets",
            "description": "Replaces the stored secrets"
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(active|paused)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "IntegrationPatch"
      },
      "IntegrationRunOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "trigger": {
            "type": "string",
            "title": "Trigger"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "topic": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Topic"
          },
          "resource_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Resource Id"
          },
          "attempts": {
            "type": "integer",
            "title": "Attempts"
          },
          "next_attempt_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Attempt At"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Started At"
          },
          "finished_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Finished At"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "detail": {
            "additionalProperties": true,
            "type": "object",
            "title": "Detail"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "trigger",
          "status",
          "topic",
          "resource_id",
          "attempts",
          "next_attempt_at",
          "started_at",
          "finished_at",
          "error",
          "detail",
          "created_at"
        ],
        "title": "IntegrationRunOut"
      },
      "JobAccepted": {
        "properties": {
          "job_id": {
            "type": "string",
            "title": "Job Id"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "review_required",
              "failed"
            ],
            "title": "Status"
          },
          "status_url": {
            "type": "string",
            "title": "Status Url"
          },
          "created": {
            "type": "boolean",
            "title": "Created",
            "description": "False when an existing job matched the idempotency key"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "job_id",
          "status",
          "status_url",
          "created"
        ],
        "title": "JobAccepted"
      },
      "JobEmailOut": {
        "properties": {
          "email_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email Id",
            "description": "The tracked email that started the job: `GET /v1/emails/{email_id}` (absent on jobs from before email tracking)"
          },
          "provider_message_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Provider Message Id",
            "description": "Its Message-ID (or the provider's id)"
          },
          "mailbox_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mailbox Id",
            "description": "The mailbox it arrived through; null when posted to `/v1/intake/email` with an API key"
          },
          "from": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "From",
            "description": "Its From address"
          },
          "to": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "To",
            "description": "Its To addresses"
          },
          "subject": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Subject"
          },
          "received_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Received At",
            "description": "When it was received, ISO 8601"
          },
          "attachment_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Attachment Count",
            "description": "Attachments, processable or not"
          },
          "processable_attachments": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Processable Attachments",
            "description": "PDF, PNG and JPEG documents taken"
          },
          "thread_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Thread Id",
            "description": "Its thread (the mailbox and the thread's root message): `GET /v1/emails/threads/{thread_id}` lists every email of it"
          },
          "supersedes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Supersedes",
            "description": "The thread's earlier job this one replaces"
          },
          "routing": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EmailRoutingOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "The router's verdict; null when not routed"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "title": "JobEmailOut",
        "description": "The email a job came in (only its envelope: the body is never kept)."
      },
      "JobEnvelope": {
        "properties": {
          "job_id": {
            "type": "string",
            "title": "Job Id"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "review_required",
              "failed"
            ],
            "title": "Status"
          },
          "source": {
            "type": "string",
            "title": "Source"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "result": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/JobResult"
              },
              {
                "type": "null"
              }
            ]
          },
          "superseded_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Superseded By",
            "description": "A later job of the same email thread that holds this job's documents and more: read that one"
          },
          "intake": {
            "$ref": "#/components/schemas/JobIntakeOut",
            "description": "How the packet came in and what it declared, for every status"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "job_id",
          "status",
          "source",
          "created_at",
          "updated_at",
          "intake"
        ],
        "title": "JobEnvelope"
      },
      "JobFileOut": {
        "properties": {
          "position": {
            "type": "integer",
            "title": "Position",
            "description": "From 0, in upload (or attachment) order"
          },
          "filename": {
            "type": "string",
            "title": "Filename"
          },
          "content_type": {
            "type": "string",
            "title": "Content Type",
            "description": "As declared by the uploader or the email"
          },
          "sha256": {
            "type": "string",
            "title": "Sha256"
          },
          "bytes": {
            "type": "integer",
            "title": "Bytes"
          },
          "from_email": {
            "type": "boolean",
            "title": "From Email",
            "description": "An email attachment"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "position",
          "filename",
          "content_type",
          "sha256",
          "bytes",
          "from_email"
        ],
        "title": "JobFileOut",
        "description": "One file the job was sent, kept sealed in storage until the job is erased."
      },
      "JobIntakeOut": {
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "email"
            ],
            "title": "Source"
          },
          "received_at": {
            "type": "string",
            "format": "date-time",
            "title": "Received At",
            "description": "When the email was received, or the upload submitted"
          },
          "broker_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Broker Email",
            "description": "The ISO / broker: the form field, or the email's sender"
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "business_ein": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Ein"
          },
          "external_business_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "External Business Id"
          },
          "end_user_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "End User Id"
          },
          "contact_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Email"
          },
          "requested_advance_amount": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Requested Advance Amount"
          },
          "email": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/JobEmailOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null for an upload"
          },
          "files": {
            "items": {
              "$ref": "#/components/schemas/JobFileOut"
            },
            "type": "array",
            "title": "Files",
            "description": "`GET /v1/jobs/{job_id}/files/{position}` returns each one's bytes"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "source",
          "received_at"
        ],
        "title": "JobIntakeOut",
        "description": "How a job's packet came in and what it declared: set from submission, whatever the job's status."
      },
      "JobListOut": {
        "properties": {
          "jobs": {
            "items": {
              "$ref": "#/components/schemas/JobSummaryOut"
            },
            "type": "array",
            "title": "Jobs"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor",
            "description": "Pass as `cursor` (with the same filters) for the next page; null on the last page"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "jobs",
          "next_cursor"
        ],
        "title": "JobListOut"
      },
      "JobResult": {
        "properties": {
          "job_id": {
            "type": "string",
            "title": "Job Id"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "review_required",
              "failed"
            ],
            "title": "Status"
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "email"
            ],
            "title": "Source"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At"
          },
          "review_reasons": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Review Reasons"
          },
          "merchant_fingerprint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Merchant Fingerprint",
            "description": "The merchant across submissions: its EIN, else its accounts and holder"
          },
          "related_jobs": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Related Jobs",
            "description": "The tenant's earlier jobs for this merchant (same EIN, or a statement in common), oldest first"
          },
          "email": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/JobEmailOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "The email the packet came in; null for an upload"
          },
          "submission_packet": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SubmissionPacketOut"
              },
              {
                "type": "null"
              }
            ]
          },
          "files": {
            "items": {
              "$ref": "#/components/schemas/FileOut"
            },
            "type": "array",
            "title": "Files"
          },
          "statements": {
            "items": {
              "$ref": "#/components/schemas/StatementOut"
            },
            "type": "array",
            "title": "Statements"
          },
          "applications": {
            "items": {
              "$ref": "#/components/schemas/ApplicationOut"
            },
            "type": "array",
            "title": "Applications"
          },
          "other_documents": {
            "items": {
              "$ref": "#/components/schemas/OtherDocumentOut"
            },
            "type": "array",
            "title": "Other Documents"
          },
          "accounts": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Accounts",
            "description": "Accepted statements grouped by account, with months covered and missing"
          },
          "months": {
            "items": {
              "$ref": "#/components/schemas/MonthOut"
            },
            "type": "array",
            "title": "Months"
          },
          "positions": {
            "items": {
              "$ref": "#/components/schemas/PositionOut"
            },
            "type": "array",
            "title": "Positions"
          },
          "underwriting": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UnderwritingOut"
              },
              {
                "type": "null"
              }
            ]
          },
          "usage": {
            "$ref": "#/components/schemas/UsageSummary"
          },
          "pipeline": {
            "additionalProperties": true,
            "type": "object",
            "title": "Pipeline"
          },
          "corrections": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CorrectionsSummary"
              },
              {
                "type": "null"
              }
            ],
            "description": "Present when corrections are in force: the result is the corrected one (`?view=computed` for the machine's), and each changed transaction, position and month carries `correction`"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "job_id",
          "status",
          "source",
          "created_at"
        ],
        "title": "JobResult"
      },
      "JobSummaryOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "title": "Tenant Id"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "review_required",
              "failed"
            ],
            "title": "Status"
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "email"
            ],
            "title": "Source"
          },
          "created_at": {
            "type": "number",
            "title": "Created At",
            "description": "Unix seconds"
          },
          "updated_at": {
            "type": "number",
            "title": "Updated At",
            "description": "Unix seconds"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At",
            "description": "Unix seconds; set once the job finished"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "intake": {
            "$ref": "#/components/schemas/JobIntakeOut"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "status",
          "source",
          "created_at",
          "updated_at",
          "intake"
        ],
        "title": "JobSummaryOut"
      },
      "JobsErasedOut": {
        "properties": {
          "end_user_id": {
            "type": "string",
            "title": "End User Id"
          },
          "erased": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Erased",
            "description": "The jobs erased now"
          },
          "still_running": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Still Running",
            "description": "Queued or running jobs, not erased: call again once they finish"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "end_user_id",
          "erased",
          "still_running"
        ],
        "title": "JobsErasedOut"
      },
      "MailboxCreate": {
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "forwarding",
              "gmail",
              "imap",
              "m365"
            ],
            "title": "Kind"
          },
          "auth": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "delegation",
                  "oauth"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Auth",
            "description": "gmail only: delegation (the funder's Workspace authorized our service account) or oauth (a mailbox of the platform's own Workspace)"
          },
          "address": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 320
              },
              {
                "type": "null"
              }
            ],
            "title": "Address",
            "description": "gmail, imap, m365: the mailbox's address"
          },
          "imap": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ImapAccess"
              },
              {
                "type": "null"
              }
            ],
            "description": "imap only: the server and login"
          },
          "organization": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200
              },
              {
                "type": "null"
              }
            ],
            "title": "Organization",
            "description": "m365 only: the funder's Microsoft tenant id or domain"
          },
          "label": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Label",
            "description": "gmail only: only messages with this label (INBOX, or one a filter applies)",
            "default": "INBOX"
          },
          "settings": {
            "$ref": "#/components/schemas/MailboxSettings"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "kind"
        ],
        "title": "MailboxCreate"
      },
      "MailboxCreated": {
        "properties": {
          "mailbox": {
            "$ref": "#/components/schemas/MailboxOut"
          },
          "inbound_secret": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Secret",
            "description": "forwarding: the secret a mail provider signs POST /v1/intake/email with (X-Mailbox-ID); shown only now"
          },
          "authorize_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Authorize Url",
            "description": "gmail oauth: open it to grant read access"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "mailbox"
        ],
        "title": "MailboxCreated"
      },
      "MailboxMessageOut": {
        "properties": {
          "id": {
            "type": "integer",
            "title": "Id"
          },
          "email_id": {
            "type": "string",
            "title": "Email Id",
            "description": "The tracked email: `GET /v1/emails/{email_id}`"
          },
          "provider_message_id": {
            "type": "string",
            "title": "Provider Message Id"
          },
          "thread_key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Thread Key"
          },
          "received_at": {
            "type": "string",
            "format": "date-time",
            "title": "Received At"
          },
          "outcome": {
            "type": "string",
            "title": "Outcome",
            "description": "job, merged, ignored:<reason> or refused"
          },
          "job_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Job Id"
          },
          "routing": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Routing"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "email_id",
          "provider_message_id",
          "thread_key",
          "received_at",
          "outcome",
          "job_id",
          "routing"
        ],
        "title": "MailboxMessageOut"
      },
      "MailboxMessagesOut": {
        "properties": {
          "messages": {
            "items": {
              "$ref": "#/components/schemas/MailboxMessageOut"
            },
            "type": "array",
            "title": "Messages"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "messages",
          "next_cursor"
        ],
        "title": "MailboxMessagesOut"
      },
      "MailboxOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "kind": {
            "type": "string",
            "title": "Kind"
          },
          "auth": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Auth"
          },
          "address": {
            "type": "string",
            "title": "Address"
          },
          "label": {
            "type": "string",
            "title": "Label"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "active",
              "paused",
              "reauth_required",
              "disconnected"
            ],
            "title": "Status"
          },
          "settings": {
            "$ref": "#/components/schemas/MailboxSettings"
          },
          "watch_expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Watch Expires At"
          },
          "last_sync_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Sync At"
          },
          "last_error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Error"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "kind",
          "auth",
          "address",
          "label",
          "status",
          "settings",
          "watch_expires_at",
          "last_sync_at",
          "last_error",
          "created_at"
        ],
        "title": "MailboxOut"
      },
      "MailboxPatch": {
        "properties": {
          "label": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Label"
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "active",
                  "paused"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          },
          "settings": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MailboxSettings"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "MailboxPatch"
      },
      "MailboxSettings": {
        "properties": {
          "auto_parse": {
            "type": "boolean",
            "title": "Auto Parse",
            "description": "Off: messages are recorded, no job is started",
            "default": true
          },
          "internal_domains": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "maxItems": 50,
            "title": "Internal Domains",
            "description": "This mailbox's staff domains, besides the tenant's"
          },
          "allowed_sender_domains": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "maxItems": 50,
            "title": "Allowed Sender Domains",
            "description": "forwarding only: take mail forwarded from these domains (and their subdomains) only, judged by the envelope sender: the mail system that forwards to the address, e.g. funder.com for a Gmail filter or Outlook rule of deals@funder.com. Other mail is ignored (sender_not_allowed). Empty: any sender"
          },
          "store_raw_email": {
            "type": "boolean",
            "title": "Store Raw Email",
            "description": "Keep each message's raw .eml (`GET /v1/emails/{email_id}/raw`). Off: only its envelope is tracked. Never kept for mail refused or from a sender not allowed",
            "default": true
          },
          "default_tags": {
            "items": {
              "type": "string",
              "description": "Trimmed and lowercased, then 1-64 of a-z 0-9 _ : -",
              "examples": [
                "client:acme"
              ]
            },
            "type": "array",
            "maxItems": 20,
            "title": "Default Tags",
            "description": "Tags every email this mailbox receives starts with, e.g. client:acme"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "MailboxSettings"
      },
      "MailboxTestOut": {
        "properties": {
          "token": {
            "type": "boolean",
            "title": "Token",
            "description": "Google issued an access token for the mailbox"
          },
          "label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Label",
            "description": "The label's id, when it could be read"
          },
          "watch_expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Watch Expires At"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "token",
          "label",
          "watch_expires_at",
          "error"
        ],
        "title": "MailboxTestOut"
      },
      "MeOut": {
        "properties": {
          "tenant": {
            "$ref": "#/components/schemas/TenantOut"
          },
          "actor_type": {
            "type": "string",
            "enum": [
              "api_key",
              "user",
              "mailbox"
            ],
            "title": "Actor Type"
          },
          "actor_id": {
            "type": "string",
            "title": "Actor Id"
          },
          "permissions": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Permissions"
          },
          "modules": {
            "additionalProperties": {
              "type": "boolean"
            },
            "type": "object",
            "title": "Modules"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "tenant",
          "actor_type",
          "actor_id",
          "permissions",
          "modules"
        ],
        "title": "MeOut"
      },
      "ModeUOut": {
        "properties": {
          "available": {
            "type": "boolean",
            "title": "Available",
            "description": "True when every decision statement is the same account, the periods follow day after day and each closing balance is the next opening balance. The underwriting block is then one unbroken history"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "unreconciled_statement",
                  "sectioned_statements",
                  "missing_account_identity",
                  "multiple_accounts",
                  "missing_statement_period",
                  "overlapping_statement_periods",
                  "non_contiguous_statement_periods",
                  "missing_balance_chain",
                  "discontinuous_balance_chain"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason"
          },
          "statement_count": {
            "type": "integer",
            "title": "Statement Count"
          },
          "account_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Count"
          },
          "gap_days": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gap Days",
            "description": "Days between two statements that do not follow on"
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "available",
          "statement_count"
        ],
        "title": "ModeUOut",
        "description": "Whether the packet's statements are one continuous history of one account."
      },
      "ModulesOut": {
        "properties": {
          "modules": {
            "additionalProperties": {
              "type": "boolean"
            },
            "type": "object",
            "title": "Modules",
            "description": "Every module (core, underwriting, positions, fraud, email_intake, email_routing, crm_sync, notifications): on or off for this tenant"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "modules"
        ],
        "title": "ModulesOut"
      },
      "MonthExclusion": {
        "properties": {
          "type": {
            "type": "string",
            "const": "month_exclusion",
            "title": "Type"
          },
          "month": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}$",
            "title": "Month",
            "description": "`months[].month`"
          },
          "account_key": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 300,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Key",
            "description": "`accounts[].account_key`: only this account's figures for the month. The month is merged again from its other accounts, so it and the averages lose exactly this account's part; null: the whole month"
          },
          "excluded": {
            "type": "boolean",
            "title": "Excluded",
            "description": "true: left out of the averages (with `account_key`: out of the month); false: counted (e.g. a partial month)"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "type",
          "month",
          "excluded"
        ],
        "title": "MonthExclusion",
        "description": "Leave a calendar month out of the underwriting averages, or count one the pipeline left out; or leave one\naccount's figures out of a month."
      },
      "MonthOut": {
        "properties": {
          "month": {
            "type": "string",
            "title": "Month"
          },
          "accounts": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Accounts"
          },
          "partial_period": {
            "type": "boolean",
            "title": "Partial Period",
            "default": false
          },
          "is_mtd": {
            "type": "boolean",
            "title": "Is Mtd",
            "default": false
          },
          "included_in_averages": {
            "type": "boolean",
            "title": "Included In Averages",
            "default": true
          },
          "deposits_total": {
            "type": "string",
            "title": "Deposits Total"
          },
          "deposits_count": {
            "type": "integer",
            "title": "Deposits Count"
          },
          "true_revenue": {
            "type": "string",
            "title": "True Revenue",
            "description": "Deposits less those identified as MCA funding, loan proceeds, transfers in, refunds/reversals, returned items or other non-sales credits"
          },
          "true_revenue_count": {
            "type": "integer",
            "title": "True Revenue Count"
          },
          "true_revenue_unlabelled": {
            "type": "string",
            "title": "True Revenue Unlabelled",
            "description": "The part of true_revenue from deposits no category identified (e.g. a bare 'Regular Deposit')",
            "default": "0"
          },
          "total_non_revenue": {
            "type": "string",
            "title": "Total Non Revenue"
          },
          "withdrawals_total": {
            "type": "string",
            "title": "Withdrawals Total"
          },
          "withdrawals_count": {
            "type": "integer",
            "title": "Withdrawals Count"
          },
          "mca_funding_total": {
            "type": "string",
            "title": "Mca Funding Total"
          },
          "loan_proceeds_total": {
            "type": "string",
            "title": "Loan Proceeds Total"
          },
          "transfers_in_total": {
            "type": "string",
            "title": "Transfers In Total"
          },
          "transfers_out_total": {
            "type": "string",
            "title": "Transfers Out Total"
          },
          "mca_debits_total": {
            "type": "string",
            "title": "Mca Debits Total"
          },
          "mca_debits_projected_total": {
            "type": "string",
            "title": "Mca Debits Projected Total"
          },
          "loan_payments_total": {
            "type": "string",
            "title": "Loan Payments Total"
          },
          "taxes_total": {
            "type": "string",
            "title": "Taxes Total"
          },
          "operating_expenses_total": {
            "type": "string",
            "title": "Operating Expenses Total"
          },
          "ebitda": {
            "type": "string",
            "title": "Ebitda"
          },
          "ebitda_margin_pct": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ebitda Margin Pct"
          },
          "holdback_pct": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Holdback Pct",
            "description": "MCA debits (cadence-projected) / true revenue x 100"
          },
          "starting_balance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Starting Balance"
          },
          "ending_balance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ending Balance"
          },
          "average_balance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Average Balance"
          },
          "negative_balance_days": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Negative Balance Days"
          },
          "low_balance_days": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Low Balance Days"
          },
          "nsf_count": {
            "type": "integer",
            "title": "Nsf Count"
          },
          "overdraft_count": {
            "type": "integer",
            "title": "Overdraft Count"
          },
          "returned_item_count": {
            "type": "integer",
            "title": "Returned Item Count"
          },
          "unknown_category_count": {
            "type": "integer",
            "title": "Unknown Category Count"
          },
          "by_account": {
            "items": {
              "$ref": "#/components/schemas/MonthOut"
            },
            "type": "array",
            "title": "By Account",
            "description": "With two or more accounts in the month: each account's own figures, which the month sums (balances summed; negative and low-balance days the most of any account). Absent with one account: the month is that account's"
          },
          "correction": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CorrectionProvenance"
              },
              {
                "type": "null"
              }
            ],
            "description": "Present only when a correction changed this item (the default, corrected view)"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "month",
          "deposits_total",
          "deposits_count",
          "true_revenue",
          "true_revenue_count",
          "total_non_revenue",
          "withdrawals_total",
          "withdrawals_count",
          "mca_funding_total",
          "loan_proceeds_total",
          "transfers_in_total",
          "transfers_out_total",
          "mca_debits_total",
          "mca_debits_projected_total",
          "loan_payments_total",
          "taxes_total",
          "operating_expenses_total",
          "ebitda",
          "ebitda_margin_pct",
          "holdback_pct",
          "starting_balance",
          "ending_balance",
          "average_balance",
          "negative_balance_days",
          "low_balance_days",
          "nsf_count",
          "overdraft_count",
          "returned_item_count",
          "unknown_category_count"
        ],
        "title": "MonthOut",
        "description": "One calendar month merged across every accepted statement and account."
      },
      "OtherDocumentOut": {
        "properties": {
          "source_file": {
            "type": "string",
            "title": "Source File"
          },
          "document_type": {
            "type": "string",
            "title": "Document Type"
          },
          "packet_pages": {
            "items": {
              "type": "integer"
            },
            "type": "array",
            "title": "Packet Pages"
          },
          "confidence": {
            "type": "number",
            "title": "Confidence"
          },
          "note": {
            "type": "string",
            "title": "Note",
            "default": "classified only; not parsed"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "source_file",
          "document_type",
          "packet_pages",
          "confidence"
        ],
        "title": "OtherDocumentOut"
      },
      "PacketDocumentOut": {
        "properties": {
          "packet_index": {
            "type": "integer",
            "title": "Packet Index"
          },
          "document_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Document Id",
            "description": "Statement / application id; null for other documents"
          },
          "kind": {
            "type": "string",
            "enum": [
              "bank_statement",
              "application",
              "other"
            ],
            "title": "Kind"
          },
          "document_type": {
            "type": "string",
            "title": "Document Type"
          },
          "declared_document_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Declared Document Type"
          },
          "source_file": {
            "type": "string",
            "title": "Source File"
          },
          "packet_pages": {
            "items": {
              "type": "integer"
            },
            "type": "array",
            "title": "Packet Pages"
          },
          "content_sha256": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content Sha256"
          },
          "content_fingerprint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content Fingerprint"
          },
          "statement_fingerprint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Statement Fingerprint"
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "review_required",
              "failed",
              "classified_only",
              "unclassified"
            ],
            "title": "Status",
            "description": "accepted / review_required / failed: the document's own gate; classified_only: a known document type that is listed, not parsed; unclassified: no type and no ledger found"
          },
          "excluded_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "unclassified_document",
                  "duplicate_document",
                  "statement_excluded_parse_failed",
                  "statement_excluded_unreconciled",
                  "activity_printout_unverified",
                  "account_holder_mismatch",
                  "period_overlaps_another_statement"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Excluded Reason",
            "description": "Why the packet's decision is not computed from this document"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "packet_index",
          "kind",
          "document_type",
          "source_file",
          "packet_pages",
          "status"
        ],
        "title": "PacketDocumentOut",
        "description": "One typed document of the packet, in packet order (file by file, page by page)."
      },
      "PacketExclusionOut": {
        "properties": {
          "packet_index": {
            "type": "integer",
            "title": "Packet Index"
          },
          "document_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Document Id"
          },
          "source_file": {
            "type": "string",
            "title": "Source File"
          },
          "document_type": {
            "type": "string",
            "title": "Document Type"
          },
          "reason_code": {
            "type": "string",
            "enum": [
              "unclassified_document",
              "duplicate_document",
              "statement_excluded_parse_failed",
              "statement_excluded_unreconciled",
              "activity_printout_unverified",
              "account_holder_mismatch",
              "period_overlaps_another_statement"
            ],
            "title": "Reason Code"
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "packet_index",
          "source_file",
          "document_type",
          "reason_code"
        ],
        "title": "PacketExclusionOut"
      },
      "PacketFraudOut": {
        "properties": {
          "fraud_score": {
            "type": "number",
            "maximum": 100.0,
            "minimum": 0.0,
            "title": "Fraud Score",
            "description": "0-100: the strongest signal's weight x 100. 60: declared revenue overstated; 85: any other signal; 95: a critical one; 0: compared and consistent"
          },
          "severity": {
            "type": "string",
            "enum": [
              "unknown",
              "clean",
              "low",
              "medium",
              "high",
              "critical"
            ],
            "title": "Severity",
            "description": "From the score: 85 and above high, 60 and above medium, above 0 low, 0 clean. high or critical sends the packet to review (`packet_cross_document_fraud`); the packet itself is never rated critical or unknown today (a reason can be critical)"
          },
          "reasons": {
            "items": {
              "$ref": "#/components/schemas/FraudReasonOut"
            },
            "type": "array",
            "title": "Reasons",
            "description": "Each signal found, strongest first"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "required": [
          "fraud_score",
          "severity"
        ],
        "title": "PacketFraudOut",
        "description": "Cross-document fraud: the packet's documents checked against each other."
      },
      "PacketIntakeOut": {
        "properties": {
          "received_at": {
            "type": "string",
            "format": "date-time",
            "title": "Received At"
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "email"
            ],
            "title": "Source"
          },
          "broker_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Broker Email",
            "description": "The ISO / broker that sent the packet (email: the sender)"
          },
          "contact_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Email"
          },
          "end_user_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "End User Id",
            "description": "The caller's merchant id, echoed"
          },
          "requested_advance_amount": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Requested Advance Amount"
          },
          "business_identity": {
            "$ref": "#/components/schemas/BusinessIdentityOut"
          },
          "file_declarations": {
            "items": {
              "$ref": "#/components/schemas/FileDeclarationOut"
            },
            "type": "array",
            "title": "File Declarations"
          },
          "request_content_sha256": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Request Content Sha256",
            "description": "Every file's name and bytes, in order, plus the declared metadata and options. An Idempotency-Key reused with a different request is refused (409)"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "received_at",
          "source",
          "business_identity"
        ],
        "title": "PacketIntakeOut"
      },
      "PageQualityAssessment": {
        "properties": {
          "page_number": {
            "type": "integer",
            "minimum": 1.0,
            "title": "Page Number"
          },
          "readiness_score": {
            "type": "number",
            "maximum": 1.0,
            "minimum": 0.0,
            "title": "Readiness Score"
          },
          "quality_score": {
            "type": "number",
            "maximum": 1.0,
            "minimum": 0.0,
            "title": "Quality Score"
          },
          "blur_variance": {
            "type": "number",
            "minimum": 0.0,
            "title": "Blur Variance"
          },
          "brightness": {
            "type": "number",
            "maximum": 255.0,
            "minimum": 0.0,
            "title": "Brightness"
          },
          "contrast": {
            "type": "number",
            "minimum": 0.0,
            "title": "Contrast"
          },
          "skew_angle_degrees": {
            "type": "number",
            "title": "Skew Angle Degrees"
          },
          "lighting_variance": {
            "type": "number",
            "minimum": 0.0,
            "title": "Lighting Variance"
          },
          "crop_box": {
            "anyOf": [
              {
                "prefixItems": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "integer"
                  },
                  {
                    "type": "integer"
                  },
                  {
                    "type": "integer"
                  }
                ],
                "type": "array",
                "maxItems": 4,
                "minItems": 4
              },
              {
                "type": "null"
              }
            ],
            "title": "Crop Box"
          },
          "photo_like": {
            "type": "boolean",
            "title": "Photo Like",
            "default": false
          },
          "blocking": {
            "type": "boolean",
            "title": "Blocking",
            "default": false
          },
          "operations_applied": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Operations Applied"
          },
          "issues": {
            "items": {
              "$ref": "#/components/schemas/ImageQualityIssue"
            },
            "type": "array",
            "title": "Issues"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "page_number",
          "readiness_score",
          "quality_score",
          "blur_variance",
          "brightness",
          "contrast",
          "skew_angle_degrees",
          "lighting_variance"
        ],
        "title": "PageQualityAssessment"
      },
      "PositionOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "key": {
            "type": "string",
            "title": "Key",
            "description": "The position's stable identity, which position overrides name: `pk_` and the first 16 hex digits of the SHA-256 of `<account_key>|<counterparty_signature>|<first_date>`",
            "default": ""
          },
          "kind": {
            "type": "string",
            "enum": [
              "mca",
              "loan"
            ],
            "title": "Kind",
            "description": "mca: counted in the MCA withhold; loan: a business loan's payments, reported only",
            "default": "mca"
          },
          "funder": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Funder",
            "description": "Funder name (Luna counterparty or seeded catalog), when known"
          },
          "counterparty_signature": {
            "type": "string",
            "title": "Counterparty Signature"
          },
          "account_key": {
            "type": "string",
            "title": "Account Key"
          },
          "cadence": {
            "type": "string",
            "title": "Cadence"
          },
          "payment_amount": {
            "type": "string",
            "title": "Payment Amount"
          },
          "occurrences": {
            "type": "integer",
            "title": "Occurrences"
          },
          "total_repaid": {
            "type": "string",
            "title": "Total Repaid"
          },
          "first_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Date"
          },
          "last_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Date"
          },
          "expected_next_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expected Next Date"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "evidence": {
            "type": "string",
            "enum": [
              "cadence",
              "cadence+luna",
              "luna_only"
            ],
            "title": "Evidence"
          },
          "evidence_strength": {
            "type": "string",
            "title": "Evidence Strength"
          },
          "detection_reason_codes": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Detection Reason Codes"
          },
          "counted_in_withhold": {
            "type": "boolean",
            "title": "Counted In Withhold"
          },
          "correction": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CorrectionProvenance"
              },
              {
                "type": "null"
              }
            ],
            "description": "Present only when a correction changed this item (the default, corrected view)"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "funder",
          "counterparty_signature",
          "account_key",
          "cadence",
          "payment_amount",
          "occurrences",
          "total_repaid",
          "first_date",
          "last_date",
          "expected_next_date",
          "is_active",
          "evidence",
          "evidence_strength",
          "counted_in_withhold"
        ],
        "title": "PositionOut"
      },
      "PositionOverride-Input": {
        "properties": {
          "type": {
            "type": "string",
            "const": "position_override",
            "title": "Type"
          },
          "position_key": {
            "type": "string",
            "maxLength": 40,
            "title": "Position Key",
            "description": "`positions[].key`"
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "active",
                  "paid_off",
                  "not_a_position"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Status",
            "description": "active: counted in the existing MCA burden whatever its last pull's date; paid_off and not_a_position: not counted"
          },
          "frequency": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "daily",
                  "weekly",
                  "biweekly"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Frequency",
            "description": "Payment frequency; the burden converts daily x21, weekly x4, biweekly x2"
          },
          "payment_amount": {
            "anyOf": [
              {
                "type": "number",
                "exclusiveMinimum": 0.0
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Payment Amount",
            "description": "The payment pulled now, USD"
          },
          "funder": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Funder"
          },
          "kind": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "mca",
                  "loan"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Kind",
            "description": "mca: counted in the withhold; loan: reported, never counted"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "type",
          "position_key"
        ],
        "title": "PositionOverride",
        "description": "Override what was detected for one position; null fields keep the computed value."
      },
      "PositionOverride-Output": {
        "properties": {
          "type": {
            "type": "string",
            "const": "position_override",
            "title": "Type"
          },
          "position_key": {
            "type": "string",
            "maxLength": 40,
            "title": "Position Key",
            "description": "`positions[].key`"
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "active",
                  "paid_off",
                  "not_a_position"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Status",
            "description": "active: counted in the existing MCA burden whatever its last pull's date; paid_off and not_a_position: not counted"
          },
          "frequency": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "daily",
                  "weekly",
                  "biweekly"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Frequency",
            "description": "Payment frequency; the burden converts daily x21, weekly x4, biweekly x2"
          },
          "payment_amount": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Payment Amount",
            "description": "The payment pulled now, USD"
          },
          "funder": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Funder"
          },
          "kind": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "mca",
                  "loan"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Kind",
            "description": "mca: counted in the withhold; loan: reported, never counted"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "type",
          "position_key"
        ],
        "title": "PositionOverride",
        "description": "Override what was detected for one position; null fields keep the computed value."
      },
      "ProfileFieldOut": {
        "properties": {
          "value": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Value",
            "description": "Resolved: the request, else the first application, else the statements' majority"
          },
          "sources": {
            "items": {
              "$ref": "#/components/schemas/ProfileSourceOut"
            },
            "type": "array",
            "title": "Sources"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "value"
        ],
        "title": "ProfileFieldOut"
      },
      "ProfileSourceOut": {
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "request",
              "iso_application",
              "bank_statement"
            ],
            "title": "Source"
          },
          "value": {
            "type": "string",
            "title": "Value"
          },
          "document_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Document Id"
          },
          "extracted_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Extracted By",
            "description": "acroform | luna | text_regex | layout"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "source",
          "value"
        ],
        "title": "ProfileSourceOut"
      },
      "ProposedOffer": {
        "properties": {
          "amount": {
            "type": "number",
            "exclusiveMinimum": 0.0,
            "title": "Amount",
            "description": "Funded amount in USD"
          },
          "factor_rate": {
            "type": "number",
            "maximum": 3.0,
            "exclusiveMinimum": 1.0,
            "title": "Factor Rate",
            "description": "Factor rate, e.g. 1.35"
          },
          "term": {
            "type": "integer",
            "maximum": 1000.0,
            "exclusiveMinimum": 0.0,
            "title": "Term",
            "description": "Number of payments (days for daily, weeks for weekly)"
          },
          "frequency": {
            "type": "string",
            "enum": [
              "daily",
              "weekly"
            ],
            "title": "Frequency",
            "default": "daily"
          },
          "fees_percent": {
            "type": "number",
            "maximum": 100.0,
            "minimum": 0.0,
            "title": "Fees Percent",
            "default": 0.0
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "amount",
          "factor_rate",
          "term"
        ],
        "title": "ProposedOffer",
        "description": "An offer to test against the merchant's withhold capacity."
      },
      "QualityTier": {
        "type": "string",
        "enum": [
          "clean_digital",
          "clean_scan",
          "low_quality_scan",
          "photo"
        ],
        "title": "QualityTier"
      },
      "RefreshIn": {
        "properties": {
          "refresh_token": {
            "type": "string",
            "maxLength": 2048,
            "minLength": 1,
            "title": "Refresh Token"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "refresh_token"
        ],
        "title": "RefreshIn"
      },
      "RowRef": {
        "properties": {
          "document_id": {
            "type": "string",
            "title": "Document Id",
            "description": "`statements[].document_id`"
          },
          "index": {
            "type": "integer",
            "minimum": 0.0,
            "title": "Index",
            "description": "`statements[].transactions[].index`"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "document_id",
          "index"
        ],
        "title": "RowRef"
      },
      "SessionOut": {
        "properties": {
          "access_token": {
            "type": "string",
            "title": "Access Token",
            "description": "Send as Authorization: Bearer; it expires in minutes"
          },
          "refresh_token": {
            "type": "string",
            "title": "Refresh Token",
            "description": "Trade for a new pair at POST /v1/auth/refresh; each one works once"
          },
          "user_id": {
            "type": "string",
            "title": "User Id"
          },
          "email": {
            "type": "string",
            "title": "Email"
          },
          "organization_id": {
            "type": "string",
            "title": "Organization Id"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "access_token",
          "refresh_token",
          "user_id",
          "email",
          "organization_id"
        ],
        "title": "SessionOut"
      },
      "StatementExclusionsOut": {
        "properties": {
          "excluded_documents": {
            "items": {
              "$ref": "#/components/schemas/PacketExclusionOut"
            },
            "type": "array",
            "title": "Excluded Documents"
          },
          "included_statement_count": {
            "type": "integer",
            "title": "Included Statement Count",
            "description": "Periodic statements the decision rests on"
          },
          "missing_months": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Missing Months",
            "description": "Months only an excluded (failed or unreconciled) statement covered"
          },
          "review_reasons": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Review Reasons"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "excluded_documents",
          "included_statement_count",
          "missing_months",
          "review_reasons"
        ],
        "title": "StatementExclusionsOut",
        "description": "Which documents a deal decision must not be computed from, and why (one reason code each)."
      },
      "StatementOut": {
        "properties": {
          "document_id": {
            "type": "string",
            "title": "Document Id"
          },
          "source_file": {
            "type": "string",
            "title": "Source File"
          },
          "content_sha256": {
            "type": "string",
            "title": "Content Sha256"
          },
          "content_fingerprint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content Fingerprint",
            "description": "What the pages say (text layer, embedded scans), whatever file they arrived in; null when a page cannot be identified safely"
          },
          "statement_fingerprint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Statement Fingerprint",
            "description": "Last four, period and opening/closing balances: the same statement in any file"
          },
          "read_reused": {
            "type": "boolean",
            "title": "Read Reused",
            "description": "The ledger was not read again: an earlier read of the same content or statement was reused",
            "default": false
          },
          "earlier_submission": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EarlierSubmissionOut"
              },
              {
                "type": "null"
              }
            ]
          },
          "image_readiness": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DocumentQualityAssessment"
              },
              {
                "type": "null"
              }
            ],
            "description": "Whether the scanned pages can be read, measured on the first image page with content before any image read; null when not measured in this job (no image read was needed, the read was reused, or the gate is off). reupload_required fails the statement with image_reupload_required: ask the merchant for a sharper, better-lit copy"
          },
          "packet_pages": {
            "items": {
              "type": "integer"
            },
            "type": "array",
            "title": "Packet Pages",
            "description": "[first, last] page of this statement in its source file"
          },
          "page_modes": {
            "additionalProperties": {
              "type": "integer"
            },
            "type": "object",
            "title": "Page Modes",
            "description": "Pages read from the text layer vs from the image"
          },
          "document_type": {
            "type": "string",
            "title": "Document Type"
          },
          "institution_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Institution Name"
          },
          "account_holder_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Holder Name"
          },
          "account_number_last4": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Number Last4"
          },
          "routing_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Routing Number"
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          },
          "statement_kind": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Statement Kind"
          },
          "months": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Months",
            "description": "Calendar months (YYYY-MM) this statement covers"
          },
          "opening_balance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Opening Balance"
          },
          "closing_balance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Closing Balance"
          },
          "summary_total_credits": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Summary Total Credits"
          },
          "summary_total_debits": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Summary Total Debits"
          },
          "credits_total": {
            "type": "string",
            "title": "Credits Total",
            "default": "0"
          },
          "debits_total": {
            "type": "string",
            "title": "Debits Total",
            "default": "0"
          },
          "credit_count": {
            "type": "integer",
            "title": "Credit Count",
            "default": 0
          },
          "debit_count": {
            "type": "integer",
            "title": "Debit Count",
            "default": 0
          },
          "accounts": {
            "items": {
              "$ref": "#/components/schemas/AccountSectionOut"
            },
            "type": "array",
            "title": "Accounts"
          },
          "gate": {
            "$ref": "#/components/schemas/GateOut"
          },
          "category_counts": {
            "additionalProperties": {
              "type": "integer"
            },
            "type": "object",
            "title": "Category Counts"
          },
          "category_conflicts": {
            "type": "integer",
            "title": "Category Conflicts",
            "default": 0
          },
          "enrichment": {
            "type": "string",
            "enum": [
              "luna_in_read",
              "luna",
              "partial",
              "failed",
              "rules_only",
              "not_run"
            ],
            "title": "Enrichment",
            "description": "luna: one labelling call (high effort) categorized every row group of the ledger; luna_in_read: that call failed and the labels Luna gave while reading the page images stand; partial/failed: some/none of the groups, rules filled the rest; rules_only: no Luna key; not_run: the ledger was withheld",
            "default": "not_run"
          },
          "enrichment_groups": {
            "type": "integer",
            "title": "Enrichment Groups",
            "description": "Description groups sent for enrichment",
            "default": 0
          },
          "transactions": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/TransactionOut"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transactions",
            "description": "Null when withheld (gate not passed and include_unverified=false)"
          },
          "checks": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Checks"
          },
          "attempts": {
            "items": {
              "$ref": "#/components/schemas/AttemptOut"
            },
            "type": "array",
            "title": "Attempts"
          },
          "cache_hit": {
            "type": "boolean",
            "title": "Cache Hit",
            "default": false
          },
          "excluded_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Excluded Reason",
            "description": "Why this statement is not in the aggregate"
          },
          "usage": {
            "$ref": "#/components/schemas/UsageSummary"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "document_id",
          "source_file",
          "content_sha256",
          "packet_pages",
          "page_modes",
          "document_type",
          "gate"
        ],
        "title": "StatementOut"
      },
      "SubmissionIntelligenceOut": {
        "properties": {
          "company_profile": {
            "$ref": "#/components/schemas/CompanyProfileOut",
            "description": "Business, address and owner fields across the request, the applications and the statements, each with every source it was read from"
          },
          "transaction_coverage": {
            "$ref": "#/components/schemas/TransactionCoverageOut"
          },
          "statement_count": {
            "type": "integer",
            "title": "Statement Count"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "company_profile",
          "transaction_coverage",
          "statement_count"
        ],
        "title": "SubmissionIntelligenceOut"
      },
      "SubmissionPacketOut": {
        "properties": {
          "packet_id": {
            "type": "string",
            "title": "Packet Id",
            "description": "The job id"
          },
          "intake": {
            "$ref": "#/components/schemas/PacketIntakeOut"
          },
          "document_count": {
            "type": "integer",
            "title": "Document Count"
          },
          "documents": {
            "items": {
              "$ref": "#/components/schemas/PacketDocumentOut"
            },
            "type": "array",
            "title": "Documents"
          },
          "statement_exclusions": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/StatementExclusionsOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null when every statement is a decision input and nothing is flagged"
          },
          "submission_intelligence": {
            "$ref": "#/components/schemas/SubmissionIntelligenceOut"
          },
          "mode_u": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ModeUOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null with fewer than two periodic decision statements"
          },
          "cross_statement": {
            "$ref": "#/components/schemas/CrossStatementOut"
          },
          "packet_fraud": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PacketFraudOut"
              },
              {
                "type": "null"
              }
            ],
            "description": "Cross-document fraud signals (balance-chain tampering, mismatched identities, reused statements): `{fraud_score, severity, reasons[]}`; null when fewer than two documents can be compared, or the fraud module is off"
          },
          "review_reasons": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Review Reasons",
            "description": "The packet's own review reasons; also in the job's `review_reasons`"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "packet_id",
          "intake",
          "document_count",
          "documents",
          "submission_intelligence",
          "cross_statement"
        ],
        "title": "SubmissionPacketOut",
        "description": "The packet as one submission: its intake, its documents and the checks across them."
      },
      "TenantCreate": {
        "properties": {
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
            "title": "Slug"
          },
          "name": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Name"
          },
          "workos_org_id": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ],
            "title": "Workos Org Id",
            "description": "An existing WorkOS organization"
          },
          "owner_email": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 320
              },
              {
                "type": "null"
              }
            ],
            "title": "Owner Email",
            "description": "Invited to the WorkOS organization as its owner"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "slug",
          "name"
        ],
        "title": "TenantCreate"
      },
      "TenantCreated": {
        "properties": {
          "tenant": {
            "$ref": "#/components/schemas/TenantOut"
          },
          "invitation_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Invitation Id"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "tenant"
        ],
        "title": "TenantCreated"
      },
      "TenantDetailOut": {
        "properties": {
          "tenant": {
            "$ref": "#/components/schemas/TenantOut"
          },
          "settings": {
            "$ref": "#/components/schemas/TenantSettingsOut"
          },
          "modules": {
            "additionalProperties": {
              "type": "boolean"
            },
            "type": "object",
            "title": "Modules"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "tenant",
          "settings",
          "modules"
        ],
        "title": "TenantDetailOut"
      },
      "TenantOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "slug": {
            "type": "string",
            "title": "Slug"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "deleted"
            ],
            "title": "Status"
          },
          "workos_org_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Workos Org Id"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "slug",
          "name",
          "status",
          "created_at"
        ],
        "title": "TenantOut"
      },
      "TenantPatch": {
        "properties": {
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "active",
                  "suspended"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          },
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "workos_org_id": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ],
            "title": "Workos Org Id"
          },
          "settings": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TenantSettingsPatch"
              },
              {
                "type": "null"
              }
            ]
          },
          "modules": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "boolean"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Modules"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason",
            "description": "Recorded in the audit log; required to change the Luna route"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "TenantPatch"
      },
      "TenantSettingsOut": {
        "properties": {
          "retention_days": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Retention Days",
            "description": "Data older than this is deleted; null keeps everything"
          },
          "max_active_jobs": {
            "type": "integer",
            "title": "Max Active Jobs"
          },
          "max_cost_usd_per_job": {
            "type": "string",
            "title": "Max Cost Usd Per Job"
          },
          "monthly_luna_budget_usd": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Monthly Luna Budget Usd"
          },
          "luna_route": {
            "type": "string",
            "enum": [
              "openrouter",
              "proxy"
            ],
            "title": "Luna Route"
          },
          "luna_route_scans": {
            "type": "string",
            "enum": [
              "openrouter",
              "proxy"
            ],
            "title": "Luna Route Scans"
          },
          "luna_failover": {
            "type": "boolean",
            "title": "Luna Failover"
          },
          "email_routing": {
            "$ref": "#/components/schemas/EmailRoutingConfig"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "retention_days",
          "max_active_jobs",
          "max_cost_usd_per_job",
          "monthly_luna_budget_usd",
          "luna_route",
          "luna_route_scans",
          "luna_failover",
          "email_routing"
        ],
        "title": "TenantSettingsOut"
      },
      "TenantSettingsPatch": {
        "properties": {
          "retention_days": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 36500.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Retention Days"
          },
          "email_routing": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EmailRoutingConfig"
              },
              {
                "type": "null"
              }
            ]
          },
          "max_active_jobs": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 10000.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Active Jobs"
          },
          "max_cost_usd_per_job": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 1000.0,
                "minimum": 0.0
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Cost Usd Per Job"
          },
          "monthly_luna_budget_usd": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.0
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Monthly Luna Budget Usd"
          },
          "luna_route": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "openrouter",
                  "proxy"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Luna Route"
          },
          "luna_route_scans": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "openrouter",
                  "proxy"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Luna Route Scans"
          },
          "luna_failover": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Luna Failover"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "TenantSettingsPatch",
        "description": "Fields left out are unchanged. The tenant may set retention and email routing; the rest is platform-only."
      },
      "TransactionCategory": {
        "type": "string",
        "enum": [
          "revenue",
          "mca_funding",
          "loan_proceeds",
          "transfer_in",
          "refund_reversal",
          "other_credit",
          "mca_payment",
          "loan_payment",
          "nsf_fee",
          "overdraft_fee",
          "returned_item",
          "bank_fee",
          "transfer_out",
          "payroll",
          "taxes",
          "operating_expense",
          "cash_withdrawal",
          "unknown"
        ],
        "title": "TransactionCategory",
        "description": "What a transaction IS, assigned by Luna per row from its own description.\n\nCategorization never decides extraction: amounts, dates, direction and\nwhich rows exist come from the source. Deterministic rules\n(``analysis.categories``) cross-check every row and flag disagreements."
      },
      "TransactionCorrection": {
        "properties": {
          "document_id": {
            "type": "string",
            "title": "Document Id",
            "description": "`statements[].document_id`"
          },
          "index": {
            "type": "integer",
            "minimum": 0.0,
            "title": "Index",
            "description": "`statements[].transactions[].index`"
          },
          "type": {
            "type": "string",
            "const": "transaction",
            "title": "Type"
          },
          "category": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TransactionCategory"
              },
              {
                "type": "null"
              }
            ],
            "description": "A category that fits the row's direction (credit or debit); null: unchanged"
          },
          "counterparty": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Counterparty",
            "description": "Null: unchanged"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "document_id",
          "index",
          "type"
        ],
        "title": "TransactionCorrection",
        "description": "Set one ledger row's category and/or counterparty. Amounts, dates, balances and the rows themselves are\nnever corrected: a verified ledger reconciles to the cent as read."
      },
      "TransactionCoverageOut": {
        "properties": {
          "accounts": {
            "items": {
              "$ref": "#/components/schemas/AccountCoverageOut"
            },
            "type": "array",
            "title": "Accounts"
          },
          "coverage_pct": {
            "type": "number",
            "title": "Coverage Pct",
            "description": "Months with a statement / months from the first to the last, x 100"
          },
          "reconciled_pct": {
            "type": "number",
            "title": "Reconciled Pct",
            "description": "Covered months whose statements passed the gate, x 100"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "coverage_pct",
          "reconciled_pct"
        ],
        "title": "TransactionCoverageOut",
        "description": "Per account, month by month: which months the packet's statements cover and whether they reconciled."
      },
      "TransactionOut": {
        "properties": {
          "index": {
            "type": "integer",
            "title": "Index"
          },
          "date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "Date"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "amount": {
            "type": "string",
            "title": "Amount",
            "description": "Signed: positive credit, negative debit"
          },
          "transaction_type": {
            "type": "string",
            "enum": [
              "credit",
              "debit"
            ],
            "title": "Transaction Type"
          },
          "running_balance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Running Balance"
          },
          "is_pending": {
            "type": "boolean",
            "title": "Is Pending",
            "default": false
          },
          "category": {
            "type": "string",
            "title": "Category"
          },
          "category_source": {
            "type": "string",
            "title": "Category Source",
            "description": "luna | rules | none"
          },
          "rule_category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Rule Category"
          },
          "category_conflict": {
            "type": "boolean",
            "title": "Category Conflict",
            "default": false
          },
          "counterparty": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Counterparty"
          },
          "is_nsf": {
            "type": "boolean",
            "title": "Is Nsf",
            "default": false
          },
          "is_overdraft": {
            "type": "boolean",
            "title": "Is Overdraft",
            "default": false
          },
          "mca_position_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mca Position Id"
          },
          "counted_as": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Counted As",
            "description": "On an `mca_payment` row of a statement the figures rest on: the category its month counts it under. `mca_payment`, unless a position decision on its payment stream set another: `loan_payment` for a business loan, the stream's own category (e.g. `operating_expense`) for one decided not a position"
          },
          "mca_projected": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mca Projected",
            "description": "On a row with `mca_position_id`: true when its month projects the position's burden from its cadence (`months[].mca_debits_projected_total`); false when the pull is not projected (a position only the row labels found is summed as observed; a business loan's payments are loan payments)"
          },
          "account_section_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Section Id"
          },
          "account_number_suffix": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Number Suffix"
          },
          "page": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Page"
          },
          "read_from": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "text",
                  "image"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Read From",
            "description": "text: the layout engine read the PDF's text layer (no model); image: GPT-6 Luna read the page image"
          },
          "correction": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CorrectionProvenance"
              },
              {
                "type": "null"
              }
            ],
            "description": "Present only when a correction changed this item (the default, corrected view)"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "index",
          "date",
          "description",
          "amount",
          "transaction_type",
          "category",
          "category_source"
        ],
        "title": "TransactionOut"
      },
      "UnderwritingOut": {
        "properties": {
          "months_included": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Months Included"
          },
          "months_excluded": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Months Excluded"
          },
          "avg_monthly_revenue": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Avg Monthly Revenue",
            "description": "Mean true revenue over months with revenue > 0 (the scorecard's)"
          },
          "avg_monthly_revenue_all_months": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Avg Monthly Revenue All Months"
          },
          "weighted_monthly_revenue": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Weighted Monthly Revenue",
            "description": "0.85 decay per month back, newest weight 1"
          },
          "avg_monthly_gross_deposits": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Avg Monthly Gross Deposits"
          },
          "avg_monthly_deposit_count": {
            "type": "number",
            "title": "Avg Monthly Deposit Count"
          },
          "avg_monthly_nsf_count": {
            "type": "number",
            "title": "Avg Monthly Nsf Count"
          },
          "avg_monthly_negative_days": {
            "type": "number",
            "title": "Avg Monthly Negative Days"
          },
          "avg_ending_balance": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Avg Ending Balance"
          },
          "avg_daily_balance": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Avg Daily Balance"
          },
          "revenue_slope_3m": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Revenue Slope 3M"
          },
          "revenue_slope_6m": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Revenue Slope 6M"
          },
          "ebitda_margin_pct": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ebitda Margin Pct",
            "description": "(sum revenue - sum operating expenses) / sum revenue x 100, IQR outlier months removed"
          },
          "ebitda_months_used": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Ebitda Months Used"
          },
          "ebitda_months_excluded_as_outliers": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Ebitda Months Excluded As Outliers"
          },
          "existing_mca_monthly_payment": {
            "type": "number",
            "title": "Existing Mca Monthly Payment",
            "description": "Monthly burden of the MCA positions counted in the withhold (daily x21, weekly x4, biweekly x2). Business loans are reported in `positions` with kind `loan` and never counted"
          },
          "existing_mca_daily_payment": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Existing Mca Daily Payment"
          },
          "current_withhold_pct": {
            "type": "number",
            "title": "Current Withhold Pct",
            "description": "Existing MCA monthly payments / avg monthly revenue x 100: MCA positions only, never loans"
          },
          "holdback_pct_avg": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Holdback Pct Avg",
            "description": "Mean of monthly cadence-projected holdback %"
          },
          "active_positions": {
            "type": "integer",
            "title": "Active Positions",
            "description": "Active MCA positions (loans excluded)"
          },
          "priced_positions": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Priced Positions",
            "description": "Active positions counted in the withhold: the position count affordability pricing reads"
          },
          "is_stacked": {
            "type": "boolean",
            "title": "Is Stacked",
            "description": "Two or more established, active MCA positions"
          },
          "ebitda_capacity_pct": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ebitda Capacity Pct",
            "description": "EBITDA margin x 1.15 (the cap on total withhold)"
          },
          "remaining_withhold_pct_ebitda": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Remaining Withhold Pct Ebitda"
          },
          "score_bands": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Score Bands",
            "description": "Scorecard withhold capacity for every score band"
          },
          "selected_band": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Selected Band"
          },
          "affordability_pricing": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Affordability Pricing"
          },
          "proposed_offer": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Proposed Offer"
          },
          "stated_vs_verified": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stated Vs Verified",
            "description": "Application's stated monthly revenue vs verified bank revenue"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "months_included",
          "months_excluded",
          "avg_monthly_revenue",
          "avg_monthly_revenue_all_months",
          "weighted_monthly_revenue",
          "avg_monthly_gross_deposits",
          "avg_monthly_deposit_count",
          "avg_monthly_nsf_count",
          "avg_monthly_negative_days",
          "avg_ending_balance",
          "avg_daily_balance",
          "revenue_slope_3m",
          "revenue_slope_6m",
          "ebitda_margin_pct",
          "ebitda_months_used",
          "ebitda_months_excluded_as_outliers",
          "existing_mca_monthly_payment",
          "existing_mca_daily_payment",
          "current_withhold_pct",
          "holdback_pct_avg",
          "active_positions",
          "is_stacked",
          "ebitda_capacity_pct",
          "remaining_withhold_pct_ebitda",
          "score_bands"
        ],
        "title": "UnderwritingOut",
        "description": "Withhold, EBITDA and revenue math over the gate-accepted months."
      },
      "UsageSummary": {
        "properties": {
          "calls": {
            "type": "integer",
            "title": "Calls",
            "default": 0
          },
          "paid_calls": {
            "type": "integer",
            "title": "Paid Calls",
            "default": 0
          },
          "replayed_calls": {
            "type": "integer",
            "title": "Replayed Calls",
            "default": 0
          },
          "document_cache_hits": {
            "type": "integer",
            "title": "Document Cache Hits",
            "default": 0
          },
          "prompt_tokens": {
            "type": "integer",
            "title": "Prompt Tokens",
            "default": 0
          },
          "cached_prompt_tokens": {
            "type": "integer",
            "title": "Cached Prompt Tokens",
            "default": 0
          },
          "completion_tokens": {
            "type": "integer",
            "title": "Completion Tokens",
            "default": 0
          },
          "reasoning_tokens": {
            "type": "integer",
            "title": "Reasoning Tokens",
            "default": 0
          },
          "cost_usd": {
            "type": "string",
            "title": "Cost Usd",
            "default": "0"
          },
          "prompt_cache_hit_rate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Prompt Cache Hit Rate",
            "description": "cached_prompt_tokens / prompt_tokens"
          },
          "by_task": {
            "additionalProperties": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "object",
            "title": "By Task"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "UsageSummary",
        "description": "Measured Luna usage (tokens as reported by OpenRouter; cost provider-reported where given)."
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "VerificationOut": {
        "properties": {
          "code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Code"
          },
          "link": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Link"
          },
          "received_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Received At"
          },
          "requested_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Requested By",
            "description": "The confirmation message's subject"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "code",
          "link",
          "received_at"
        ],
        "title": "VerificationOut"
      },
      "WebhookCreate": {
        "properties": {
          "url": {
            "type": "string",
            "title": "Url",
            "description": "HTTPS URL that receives a signed POST for each event; it must resolve to a public address",
            "examples": [
              "https://crm.example.com/hooks/parser"
            ]
          },
          "topics": {
            "items": {
              "type": "string",
              "enum": [
                "job.completed",
                "job.review_required",
                "job.failed",
                "job.corrected",
                "mailbox.disconnected",
                "email.received"
              ]
            },
            "type": "array",
            "title": "Topics",
            "description": "Events to receive; empty = every topic except the opt-in `job.corrected` and `email.received`, which go only to endpoints that list them"
          },
          "description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "url"
        ],
        "title": "WebhookCreate"
      },
      "WebhookCreated": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "url": {
            "type": "string",
            "title": "Url"
          },
          "topics": {
            "items": {
              "type": "string",
              "enum": [
                "job.completed",
                "job.review_required",
                "job.failed",
                "job.corrected",
                "mailbox.disconnected",
                "email.received"
              ]
            },
            "type": "array",
            "title": "Topics"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "active": {
            "type": "boolean",
            "title": "Active"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "breaker_open_until": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Breaker Open Until",
            "description": "Set while five failures in a row pause deliveries to this endpoint"
          },
          "secret": {
            "type": "string",
            "title": "Secret",
            "description": "Signing secret for X-Parser-Signature. Shown only now (and on rotation); store it"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "url",
          "topics",
          "active",
          "created_at",
          "secret"
        ],
        "title": "WebhookCreated"
      },
      "WebhookDeliveryOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "event_id": {
            "type": "string",
            "title": "Event Id",
            "description": "X-Parser-Event-Id: the same on every retry of one event"
          },
          "topic": {
            "type": "string",
            "title": "Topic"
          },
          "resource_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Resource Id",
            "description": "The job id"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "delivered",
              "dead",
              "cancelled"
            ],
            "title": "Status"
          },
          "attempt_count": {
            "type": "integer",
            "title": "Attempt Count"
          },
          "status_code": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status Code"
          },
          "last_error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Error"
          },
          "next_attempt_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Attempt At"
          },
          "last_attempt_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Attempt At"
          },
          "delivered_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Delivered At"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "event_id",
          "topic",
          "status",
          "attempt_count",
          "created_at"
        ],
        "title": "WebhookDeliveryOut"
      },
      "WebhookOut": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "url": {
            "type": "string",
            "title": "Url"
          },
          "topics": {
            "items": {
              "type": "string",
              "enum": [
                "job.completed",
                "job.review_required",
                "job.failed",
                "job.corrected",
                "mailbox.disconnected",
                "email.received"
              ]
            },
            "type": "array",
            "title": "Topics"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "active": {
            "type": "boolean",
            "title": "Active"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "breaker_open_until": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Breaker Open Until",
            "description": "Set while five failures in a row pause deliveries to this endpoint"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "id",
          "url",
          "topics",
          "active",
          "created_at"
        ],
        "title": "WebhookOut"
      },
      "WebhookTestAccepted": {
        "properties": {
          "event_id": {
            "type": "string",
            "title": "Event Id"
          },
          "detail": {
            "type": "string",
            "title": "Detail",
            "default": "a ping event is queued for this endpoint; see its deliveries"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "event_id"
        ],
        "title": "WebhookTestAccepted"
      },
      "WithholdMonthIn": {
        "properties": {
          "month": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}$",
            "title": "Month"
          },
          "revenue": {
            "type": "number",
            "title": "Revenue",
            "description": "True revenue for the month (USD)"
          },
          "operating_expenses": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Operating Expenses",
            "description": "For the EBITDA margin; omit to supply ebitda_margin_pct"
          },
          "gross_deposits": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gross Deposits"
          },
          "deposit_count": {
            "type": "number",
            "title": "Deposit Count",
            "default": 0
          },
          "nsf_count": {
            "type": "number",
            "title": "Nsf Count",
            "default": 0
          },
          "negative_days": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Negative Days"
          },
          "ending_balance": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ending Balance"
          },
          "average_balance": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Average Balance"
          },
          "excluded": {
            "type": "boolean",
            "title": "Excluded",
            "description": "Underwriter exclusion: the month is left out",
            "default": false
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "month",
          "revenue"
        ],
        "title": "WithholdMonthIn",
        "description": "One month of an underwriter-edited monthly table (a monthly summary row)."
      },
      "WithholdRequest": {
        "properties": {
          "months": {
            "items": {
              "$ref": "#/components/schemas/WithholdMonthIn"
            },
            "type": "array",
            "minItems": 1,
            "title": "Months"
          },
          "cash_advances": {
            "items": {
              "$ref": "#/components/schemas/CashAdvanceIn"
            },
            "type": "array",
            "title": "Cash Advances",
            "description": "The MCA positions to count; business loans are not part of the withhold"
          },
          "ebitda_margin_pct": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ebitda Margin Pct",
            "description": "Override; else computed from operating_expenses"
          },
          "stated_monthly_revenue": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stated Monthly Revenue"
          },
          "score": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 100.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Score"
          },
          "factor_rate": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 3.0,
                "exclusiveMinimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Factor Rate"
          },
          "proposed_offer": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProposedOffer"
              },
              {
                "type": "null"
              }
            ]
          },
          "affordability": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AffordabilityOverrides"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "months"
        ],
        "title": "WithholdRequest",
        "description": "Recompute the withhold/EBITDA/capacity math from supplied months and positions."
      }
    },
    "securitySchemes": {
      "APIKeyHeader": {
        "type": "apiKey",
        "description": "API key",
        "in": "header",
        "name": "X-API-Key"
      },
      "HTTPBearer": {
        "type": "http",
        "description": "API key or AuthKit access token",
        "scheme": "bearer"
      }
    }
  },
  "tags": [
    {
      "name": "parse",
      "description": "Submit documents for parsing"
    },
    {
      "name": "email",
      "description": "Submit a raw email; its attachments are parsed as one packet"
    },
    {
      "name": "jobs",
      "description": "Poll jobs and read results"
    },
    {
      "name": "underwriting",
      "description": "Withhold, EBITDA and capacity calculator"
    },
    {
      "name": "webhooks",
      "description": "Signed job events pushed to your endpoint, retried until delivered"
    },
    {
      "name": "usage",
      "description": "Token usage, cost and service metrics"
    },
    {
      "name": "identity",
      "description": "Who is calling: tenant, permissions, modules"
    },
    {
      "name": "tenant",
      "description": "This tenant's settings"
    },
    {
      "name": "api-keys",
      "description": "Scoped API keys: create, rotate, revoke"
    },
    {
      "name": "mailboxes",
      "description": "Forwarding addresses and Gmail mailboxes, and each message's outcome"
    },
    {
      "name": "emails",
      "description": "Every inbound email tracked: its thread, raw .eml, tags and erasure"
    },
    {
      "name": "integrations",
      "description": "Connections to the tenant's CRM and other systems, fed by job events"
    },
    {
      "name": "audit",
      "description": "Every change made in the tenant"
    },
    {
      "name": "platform",
      "description": "Tenants across the platform (platform:admin)"
    },
    {
      "name": "health",
      "description": "Liveness and readiness"
    }
  ],
  "servers": [
    {
      "url": "https://api.parser-app.com"
    }
  ]
}
