{
  "openapi": "3.0.3",
  "info": {
    "title": "fineelik API",
    "version": "1",
    "description": "The fineelik API connects a leading system (for example ELO or an ERP) with fineelik, an accounts payable automation platform. A system can hand invoices to fineelik, follow their state, fetch changes as events, read the export data of each invoice and report an approval that ran outside fineelik.\n\nAll paths are relative to your own instance, for example `https://<instance>`. Requests and responses are JSON (UTF-8), except file uploads (multipart) and file downloads.\n\n## Authentication\n\nMachines authenticate with an API key in the header `x-api-key` on every call. No cookie or session is needed.\n\n- Create a key in the web app under Settings, API keys (administrators only). The key is shown in plain text exactly once.\n- A key expires after one year at most and can be revoked at any time.\n- A key can do at most three things: upload invoices (`invoices.upload`), read their state (`invoices.read`) and report an approval from outside (`invoices.decide_external`). It can never do more, whoever owns it.\n- A key cannot do more than its owner may. Reporting an approval needs the permission `invoices.decide_external` on the owner, which currently only the administrator role holds.\n- A route that needs any other permission answers 403 for a key, even if the owner is an administrator.\n- Webhooks are managed by signed-in users, not by keys (security scheme `SessionCookie`).\n\n## Companies\n\nA **company** (German: \"Buchungskreis\") is the accounting unit an invoice belongs to. One instance can hold several companies, for example one per client. Every invoice belongs to exactly one company; the fields `companyId` and `companyCode` identify it.\n\nA key can be bound to one company when it is created. A bound key uploads into that company and reads only its invoices, events and exports, and only as long as its owner may see the company (checked on every call). A key without binding uses the default company of the instance. A key without a valid company reads nothing and gets 403 `api_key.no_company` when it uploads.\n\n## Conventions\n\n- Money amounts are decimal strings such as `\"1234.56\"`, never floating point numbers.\n- Dates are `YYYY-MM-DD`. Timestamps are ISO 8601 in UTC.\n- Ids are UUIDs. Event ids are numbers written as strings.\n- Processing is asynchronous. After an upload fineelik extracts the data and enriches it (vendor, duplicate check, templates). Then accounting reviews the invoice, or it goes straight to approval. Read the status with `getInvoice` or follow `listIntegrationEvents`.\n\n## Errors\n\nEvery error answers with the body described in `ApiError`. The `message` is plain text in German, written for people and logs. Do not parse it. You can rely on the HTTP status code and, where present, on the stable `code` and `params`.\n\n## Limits\n\n- By default at most 60 uploads per minute per key and at most 600 calls per minute per address under `/api`. Beyond that the API answers 429 with the header `Retry-After` (seconds).\n- Upload one file at a time, wait the time given in `Retry-After` on 429, and retry with a pause on 5xx.\n\n## Invoice status\n\nThe field `status` of an invoice has one of these values:\n\n- `captured`: received, processing is not finished.\n- `extracted`: the data is read from the document, enrichment is still to come.\n- `review_required`: waits for review by accounting.\n- `enriched`: the account coding is done (in the web app \"Kontiert\"). With `statusReason` `approval_external` the invoice waits for the leading system to report the approval decision.\n- `approval_pending`: the approval runs inside fineelik.\n- `approved`, `rejected`: result of the approval. A rejected invoice can return to review.\n- `payment_pending`: an open item that waits for payment approval.\n- `payment_approved`: payment is approved, the invoice waits to be paid.\n- `paid`: paid.\n- `archived`: filed. `written_off`: written off instead of paid. `cancelled`: cancelled.\n- `duplicate`: confirmed as a duplicate of another invoice. `not_an_invoice`: marked as no invoice. `preflight_rejected`: rejected automatically before extraction.\n- `deleted`: in the trash. Invoices in the trash are not visible to API keys.\n\nDuring processing `statusReason` can be `<step>_retry: <text>` (another automatic attempt follows) or `<step>_failed: <text>` (no further automatic attempt; an event `invoice.processing_failed` is created)."
  },
  "servers": [
    {
      "url": "/",
      "description": "Your own fineelik instance, for example `https://<instance>`. All paths are relative to it."
    }
  ],
  "security": [
    {
      "ApiKey": []
    }
  ],
  "tags": [
    {
      "name": "Ingest",
      "description": "Hand invoices to fineelik: a plain upload or the hand over from a document management system such as ELO."
    },
    {
      "name": "Invoices",
      "description": "Read invoices and their state, document, history and approval record, and report an approval that ran outside fineelik."
    },
    {
      "name": "Integration",
      "description": "Interface for the leading system: the stream of events, the export state of an invoice and the lookup by DMS GUID. Instead of polling the events you can receive them as webhooks (see Webhooks)."
    },
    {
      "name": "Contracts",
      "description": "Contracts managed in ELO Contract (module \"Contracts\"): hand over from ELO, the state with the fineelik fields, and the contract document. Changes come back as events `agreement.*` in the same stream as the invoice events."
    },
    {
      "name": "Webhooks",
      "description": "Webhooks push events to a URL of the leading system, so that it does not have to poll. They carry the same events as `listIntegrationEvents`. A webhook is only the trigger: the receiver reads the data afterwards as usual with `getInvoiceExport`.\n\n**Who manages webhooks.** Signed-in users with the permission `settings.manage` (create, change, delete, renew the secret, send a test call) or `settings.read` (list, read the delivery log), in the web app under Settings, Interfaces. API keys can neither see nor create webhooks: these routes use the session cookie (`SessionCookie`), not `x-api-key`. A user sees and changes a webhook only if the user's company access covers its whole scope.\n\n**Subscription.** A webhook has a target `url` (https only, no credentials in the address, up to 500 characters), at least one event type, an optional description, an `active` switch (a webhook never switches itself off) and optionally one company. Without a company it covers all companies the creator can see at that moment. This scope is stored; what is delivered is cut to what the creator can still see at delivery time.\n\n**Secret.** fineelik generates a secret (`whsec_` followed by 32 random bytes) unless you pass your own when creating or renewing (24 to 200 characters, for example the one entered in ELO Flows). The secret appears exactly once, in the answer to creating or renewing. It is stored encrypted and never shown again, not in lists and not in any history. After renewing, only the new secret is valid.\n\n**Address with token (ELO Flows).** ELO Flows cannot verify the signature header (Flows gives no headers to triggers) and secures its webhook input with a token in the address, for example `https://<elo>/<path>/webhook?token=<token>`. Such a token is a secret like the signing secret. The address is stored and delivered in full, but every answer, log and error text shows only the masked form: values of query parameters and a fragment become `***`, names stay (`https://elo.example.test/flows?token=***&x=***`). `urlHasSecret` is then `true`. To change the address, send the complete new address. An address that contains `***` is refused with 400 `webhook.url_masked`, so that nobody saves the masked form. ELO Flows also checks the WebSub signature (`X-Hub-Signature`) when a secret is set in Flows: enter the same secret (at least 24 characters) in Flows and in fineelik.\n\n**Delivery.** fineelik sends an HTTPS POST for each event, with the body described in `WebhookEvent`. Any 2xx status counts as delivered. Everything else counts as failed: another status, a redirect (fineelik follows none), no answer within 10 seconds, a connection or certificate error. The answer body is neither read nor stored. Answer with 2xx immediately and do the work afterwards.\n\n**Order and retries.** Events go out one after the other per webhook, in ascending `id`. When a delivery fails, the webhook stays at this event and tries again after 1, 5, 15 and 60 minutes, then every 6 hours. A successful test call, a changed address or resuming after a pause triggers the next attempt at once. Delivery is at least once: after an abort the same event can arrive twice, so recognize it by its `id`. An event goes out 10 seconds after it was created at the earliest, normally within 10 to 30 seconds. A new webhook starts at the current end of the event stream and does not deliver the past (use `listIntegrationEvents` for that). Changes to a webhook apply immediately: after a change, at most the event in flight still goes out with the old settings.\n\n**What is delivered.** Only what the creator can see now. If the creator loses access to a company, its events stop. If nothing is left, the account is disabled or deleted, or the creator lacks `invoices.read`, the webhook delivers nothing: `lastError` is then `webhook.creator_no_access`, `pendingEvents` is 0, and the web app shows \"no access\". When access returns, the next cycle delivers the events since then. Otherwise create the webhook again with an account that has access.\n\n**Allowed targets.** fineelik delivers only to public addresses. Before every delivery the name is resolved and every address is checked; one blocked address is enough to refuse. Blocked are private (10/8, 172.16/12, 192.168/16), loopback (127/8, ::1), link-local (169.254/16, fe80::/10, which includes cloud metadata services), unique local (fc00::/7), carrier-grade NAT (100.64/10), multicast, unspecified and reserved addresses, also when wrapped as IPv4 in IPv6 and as an IP literal in the address. The connection goes to exactly the checked addresses, without a second resolution. The error text for a blocked address, an unresolvable name and an empty answer is deliberately the same, so that test calls cannot be used to probe internal names. Instances that a single customer runs in its own network can allow internal targets by operator configuration; https stays mandatory.\n\n**Audit.** Creating, changing, deleting and renewing the secret are recorded in the audit log, without the secret and with the masked address."
    },
    {
      "name": "Operations",
      "description": "Health of the instance."
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "tags": [
          "Operations"
        ],
        "operationId": "getHealth",
        "summary": "Check the health of the instance",
        "description": "Public route, no API key needed. Reports whether database, job queue and file storage work, and which version runs.\n\nAnswers 200 when everything is fine. When a check fails the answer is 503 with a body of the same shape. Meant for monitoring.",
        "security": [],
        "responses": {
          "200": {
            "description": "The instance is healthy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "503": {
            "description": "A check failed (database, queue or file storage).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices/upload": {
      "post": {
        "tags": [
          "Ingest"
        ],
        "operationId": "uploadInvoice",
        "summary": "Upload an invoice",
        "x-required-permissions": [
          "invoices.upload"
        ],
        "description": "Hands one invoice to fineelik. Send a multipart form with the field `file`: exactly one PDF per call (containers must be split before). Processing then runs asynchronously: read the state with `getInvoice` or follow the events.\n\n**Idempotent by content.** The same file (SHA-256) in the same company answers 200 with `duplicate: true` and the existing invoice, instead of creating a second one. A job may therefore send the same file again after a network error. By default the instance refuses such a repeat this way (an instance can be configured to accept repeats as new invoices). The same file in another company is created there as new. Id and status of an invoice from a foreign company never appear in an answer.\n\n**Company.** A key always uploads into its own company (without binding: the default company). The field `companyId` is meant for signed-in users. With a key, a different `companyId` answers 404.\n\nRate limit: by default at most 60 uploads per minute per key, then 429 with `Retry-After`.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The invoice as a PDF file. Exactly one file per call."
                  },
                  "companyId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Company to upload into. Meant for signed-in users. An API key always uploads into its own company (without binding: the default company); a different value answers 404."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The same file was already known in this company (`duplicate` is `true`). Nothing new was created; the body names the existing invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadResponse"
                }
              }
            }
          },
          "201": {
            "description": "The invoice was created and processing started.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadResponse"
                }
              }
            }
          },
          "400": {
            "description": "No file (`upload.no_file`), not a PDF (`upload.not_pdf`) or an invalid `companyId`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.upload`. Also 403 `api_key.no_company` when the key is bound to no company that its owner may see.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The `companyId` differs from the company of the key (`company.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "413": {
            "description": "The file is larger than the limit of 20 MB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit reached. Wait the number of seconds given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds until the next attempt.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "/api/ingest/handover": {
      "post": {
        "tags": [
          "Ingest"
        ],
        "operationId": "handoverInvoice",
        "summary": "Hand over an invoice from a document management system",
        "x-required-permissions": [
          "invoices.upload"
        ],
        "description": "For the ELO integration component. The component reads a document from the document management system (DMS, for example ELO) and pushes it to fineelik. fineelik needs no access to the DMS for this. Send a multipart form with the PDF in the field `file` and the text fields below, `dmsGuid` being required.\n\n**Idempotent by `dmsGuid`.** The same GUID in the same company answers 200 with `duplicate: true` and the existing invoice. The GUID is unique across the instance. When it already belongs to a different company (for example the same document sent with the key of another client), the answer is 409 `ingest.dms_guid_other_company`, without any information about the other invoice. As with `uploadInvoice`, the same file content in the same company is a duplicate too.\n\n**Company.** A key always hands over into its own company (without binding: the default company). There is no `companyId` field.\n\nThe invoice is processed asynchronously like an upload.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "dmsGuid"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The invoice as a PDF file. Exactly one file per call."
                  },
                  "dmsGuid": {
                    "type": "string",
                    "minLength": 1,
                    "description": "GUID of the document in the document management system. This is the anchor for idempotency and unique across the instance. GUID-shaped values are normalized to the ELO notation `(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)`, so notation differences (braces, case) do not matter."
                  },
                  "containerGuid": {
                    "type": "string",
                    "minLength": 1,
                    "description": "GUID of the folder in container mode. Kept only as a note in the history."
                  },
                  "mask": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Mask (document type) of the source document. Kept only as a note in the history."
                  },
                  "sourcePath": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Path of the source document. Kept only as a note in the history."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The document (`dmsGuid`) or the same file was already known in this company (`duplicate` is `true`). Nothing new was created; the body names the existing invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadResponse"
                }
              }
            }
          },
          "201": {
            "description": "The invoice was created and processing started.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadResponse"
                }
              }
            }
          },
          "400": {
            "description": "No file (`upload.no_file`), not a PDF (`upload.not_pdf`) or `dmsGuid` is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.upload`. Also 403 `api_key.no_company` when the key is bound to no company that its owner may see.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "The `dmsGuid` already belongs to a different company (`ingest.dms_guid_other_company`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "413": {
            "description": "The file is larger than the limit of 20 MB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "operationId": "listInvoices",
        "summary": "List invoices",
        "x-required-permissions": [
          "invoices.read"
        ],
        "description": "Lists invoices with filters, sorting and paging (`page`, `pageSize`, up to 500 per page). A key sees only the invoices of its own company.\n\nTo find the invoices that wait for an approval from outside, filter with `status=enriched` and look at the field `statusReason` (`approval_external`).",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only invoices with this status.",
            "schema": {
              "type": "string",
              "enum": [
                "captured",
                "preflight_rejected",
                "not_an_invoice",
                "extracted",
                "review_required",
                "enriched",
                "approval_pending",
                "approved",
                "rejected",
                "payment_pending",
                "payment_approved",
                "paid",
                "archived",
                "duplicate",
                "written_off",
                "cancelled",
                "deleted"
              ]
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Search text, 1 to 200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Only invoices of this company (within your access).",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          },
          {
            "name": "view",
            "in": "query",
            "required": false,
            "description": "A predefined group of statuses, as in the tabs of the invoice list in the web app. `all` leaves out the trash. `trash` is reserved for signed-in users who may delete invoices; an API key gets 403 `invoice.trash_forbidden`.",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "review",
                "approval",
                "ready",
                "run",
                "issues",
                "processing",
                "trash"
              ]
            }
          },
          {
            "name": "vendorId",
            "in": "query",
            "required": false,
            "description": "Only invoices of this vendor.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          },
          {
            "name": "vendorIds",
            "in": "query",
            "required": false,
            "description": "Several vendor ids separated by commas (1 to 50), for the same vendor in several companies. Together with `vendorId` it means \"one of these\".",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dueFrom",
            "in": "query",
            "required": false,
            "description": "Earliest due date, inclusive (`YYYY-MM-DD`).",
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
            }
          },
          {
            "name": "dueTo",
            "in": "query",
            "required": false,
            "description": "Latest due date, inclusive (`YYYY-MM-DD`).",
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
            }
          },
          {
            "name": "discount",
            "in": "query",
            "required": false,
            "description": "`open`: only invoices with a cash discount whose period still runs.",
            "schema": {
              "type": "string",
              "enum": [
                "open"
              ]
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "description": "Only invoices in this currency (ISO 4217, for example `EUR`).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Z]{3}$"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "required": false,
            "description": "Earliest invoice date, inclusive (`YYYY-MM-DD`).",
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "required": false,
            "description": "Latest invoice date, inclusive (`YYYY-MM-DD`).",
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
            }
          },
          {
            "name": "amountMin",
            "in": "query",
            "required": false,
            "description": "Smallest gross amount, inclusive, as a decimal string.",
            "schema": {
              "type": "string",
              "pattern": "^-?\\d+(\\.\\d+)?$"
            }
          },
          {
            "name": "amountMax",
            "in": "query",
            "required": false,
            "description": "Largest gross amount, inclusive, as a decimal string.",
            "schema": {
              "type": "string",
              "pattern": "^-?\\d+(\\.\\d+)?$"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Column to sort by. Empty values (no date, no amount) come last. Default `createdAt`.",
            "schema": {
              "default": "createdAt",
              "type": "string",
              "enum": [
                "createdAt",
                "invoiceDate",
                "dueDate",
                "grossTotal",
                "netTotal",
                "vendorName",
                "invoiceNumber",
                "status"
              ]
            }
          },
          {
            "name": "direction",
            "in": "query",
            "required": false,
            "description": "Sort direction. Default `desc`, so the newest come first.",
            "schema": {
              "default": "desc",
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "Page number, starting at 1. Default 1.",
            "schema": {
              "default": 1,
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Invoices per page, 1 to 500. Default 25.",
            "schema": {
              "default": 25,
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of the list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceList"
                }
              }
            }
          },
          "400": {
            "description": "A parameter is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.read`. Also 403 `invoice.trash_forbidden` for `view=trash`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices/{id}": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "operationId": "getInvoice",
        "summary": "Get an invoice",
        "x-required-permissions": [
          "invoices.read"
        ],
        "description": "Returns the invoice with its status, header and line data, account coding, approval and payment state, references (duplicate, reversal) and its company. A key sees only invoices of its own company. An invoice of another company, an unknown id and an invoice in the trash all answer 404.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the invoice.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceDetail"
                }
              }
            }
          },
          "400": {
            "description": "The id is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The invoice does not exist, lies outside the company of the key or is in the trash (`invoice.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices/{id}/pdf": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "operationId": "getInvoiceDocument",
        "summary": "Download the document of an invoice",
        "x-required-permissions": [
          "invoices.read"
        ],
        "description": "Returns the document as it was received. This is normally a PDF. An e-invoice that came in as an XML file is returned as an attachment with the type `application/xml`. An invoice created from an expense receipt can have an image as its document.\n\nEvery download is recorded in the audit log together with the API key.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the invoice.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The document, as a file.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/xml": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/heic": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "The id is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The invoice or its document does not exist (`invoice.original_not_found`), lies outside the company of the key or is in the trash (`invoice.not_found`). Invoices without a document, such as imported open items, have none to download.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices/{id}/audit": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "operationId": "listInvoiceHistory",
        "summary": "Get the history of an invoice",
        "x-required-permissions": [
          "invoices.read"
        ],
        "description": "Returns the history (audit trail) of the invoice, newest first, limited to the latest 200 entries. The entries about the approval tasks of the invoice belong to it. Each entry names the action, who acted (a user, or an API key in `actorApiKeyId`) and the state before and after.\n\nAn approval reported from outside (`submitExternalDecision`) appears as `invoice.status_changed`, with `decidedBy`, `comment` and `externalRef` in `metadata` and the API key as the actor.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the invoice.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The history entries.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceHistory"
                }
              }
            }
          },
          "400": {
            "description": "The id is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The invoice does not exist, lies outside the company of the key or is in the trash (`invoice.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices/{id}/approval-record": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "operationId": "downloadApprovalRecord",
        "summary": "Download the approval record of an invoice",
        "x-required-permissions": [
          "invoices.read"
        ],
        "description": "Returns the approval record (\"Freigabenachweis\") as a file download: the header of the invoice, the approval chain with all intermediate steps, queries and the history. It is meant to be passed on to a bank, tax advisor or auditor. An approval reported from outside shows the decider, the reason and the reference.\n\nThe language of the file is the language of the account that owns the key.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the invoice.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "File format. Default `pdf`.",
            "schema": {
              "type": "string",
              "enum": [
                "pdf",
                "csv"
              ],
              "default": "pdf"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The approval record as an attachment.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "The id is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The invoice does not exist, lies outside the company of the key or is in the trash.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices/{id}/external-decision": {
      "post": {
        "tags": [
          "Invoices"
        ],
        "operationId": "submitExternalDecision",
        "summary": "Report an approval decision from outside",
        "x-required-permissions": [
          "invoices.decide_external"
        ],
        "description": "Reports the decision of an approval that ran outside fineelik, for example in an ELO workflow.\n\n**When it applies.** For each company the settings say whether invoices are approved \"in fineelik\" or \"outside\". Without a licence for the approvals module every company counts as \"outside\" and the setting is locked. With \"outside\", fineelik creates no approval task after the review. The invoice stays in the status `enriched` (\"Kontiert\") with `statusReason` `approval_external` until the leading system reports the decision here. `approved` sets the invoice to `approved`, `rejected` sets it to `rejected`. Open items and the payment run then continue as usual. `listInvoices` with `status=enriched` shows which invoices wait. Invoices that were already coded before a company was switched to \"outside\" (`enriched` with another reason or none) can be reported too. Invoices in a running internal approval (`approval_pending`) cannot.\n\n**Idempotent.** A job may send the same decision again after a network error: the answer is 200 with `applied: false`, even if the company was switched to \"in fineelik\" in the meantime. A contradicting decision for an invoice that was already reported is not applied (409 `approval.external_conflict`). When two reports arrive at the same time, the first wins and the second gets the answer for the state that then holds.\n\n**History.** The report appears in the history of the invoice (`invoice.status_changed` with `decidedBy`, `comment`, `externalRef` and the key as the actor) and in the approval record with decider, reason and reference.\n\n**After the report.** After a rejection (`rejected`, reason `approval_external_rejected`), accounting can bring the invoice back into review in fineelik and close it again. It then waits for a decision once more, and the leading system restarts it after its own clarification. After an approval (`approved` with reason `approval_external_approved`, and in the payment states `payment_pending` and `payment_approved` as long as this approval is the latest), fineelik locks reopening (409 `invoice.reopen_locked_external`): corrections have to be made in the leading system.\n\nA key reports only for invoices of its own company.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the invoice.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalDecisionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The decision was applied (`applied` is `true`) or was already on record (`applied` is `false`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalDecisionResponse"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid: `decision` is missing or unknown, a field is too long or an unknown field was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.decide_external`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The invoice does not exist, lies outside the access, or is not in the company the key is bound to (`invoice.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflict. Look at `code`: `approval.external_not_enabled` (the approval of this company runs in fineelik), `approval.external_wrong_status` (the invoice does not wait for a report; `params.status` names its status) or `approval.external_conflict` (it was decided differently already).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/invoices/{id}/export": {
      "get": {
        "tags": [
          "Integration"
        ],
        "operationId": "getInvoiceExport",
        "summary": "Get the export state of an invoice",
        "x-required-permissions": [
          "invoices.read"
        ],
        "description": "Returns the neutral export state of the invoice for the leading system: header, vendor, company, amounts as decimal strings, tax lines, payment terms, payment method, account coding, booking lines and document positions. The typical flow: learn about a change from `listIntegrationEvents` (or a webhook), then read the export of that invoice here.\n\n`revision` and `dataRevision` tell what changed. `revision` changes with anything in the export. `dataRevision` changes only when data change that the receiver writes into its own invoice, so a pure status change leaves it alone. See the schema `InvoiceExport` for the details.\n\nA key reads only invoices of its own company. An invoice of another company, an unknown id and an invoice in the trash answer 404.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the invoice.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The export state of the invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceExport"
                }
              }
            }
          },
          "400": {
            "description": "The id is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The invoice does not exist, lies outside the company of the key or is in the trash (`invoice.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/integration/events": {
      "get": {
        "tags": [
          "Integration"
        ],
        "operationId": "listIntegrationEvents",
        "summary": "Fetch events",
        "x-required-permissions": [
          "invoices.read"
        ],
        "description": "Returns the events about invoices in ascending order, starting after the number `after`. fineelik writes every change that matters to the outside as an event into one continuous stream; this route and the webhooks read the same stream.\n\n**Polling.** Start with `after=0` (or leave it out). Remember `nextCursor` of each answer and pass it as `after` in the next call. When `hasMore` is `true`, call again at once. By default 100 events are returned, at most 200.\n\n**Event types.** `invoice.received` (accepted), `invoice.status_changed` (every change of status, with `previousStatus`), `invoice.export_changed` (data relevant for the export changed after review without a change of status, for example the account coding was corrected or the vendor changed) and `invoice.processing_failed` (see the schema `IntegrationEvent`). After an event, read the data with `getInvoiceExport`.\n\nA key sees only the events of its own company.",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "Return the events after this event number. Default `0`, which means from the beginning. Use `nextCursor` of the previous answer.",
            "schema": {
              "default": "0",
              "type": "string",
              "pattern": "^\\d{1,19}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Number of events per call, 1 to 200. Default 100.",
            "schema": {
              "default": 100,
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "types",
            "in": "query",
            "required": false,
            "description": "Comma separated list of event types, for example `invoice.status_changed,invoice.export_changed`. Default: all types.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Only events of this company (within your access).",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of events.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationEvents"
                }
              }
            }
          },
          "400": {
            "description": "A parameter is invalid, for example an unknown event type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/integration/invoices/by-dms-guid/{guid}": {
      "get": {
        "tags": [
          "Integration"
        ],
        "operationId": "findInvoiceByDmsGuid",
        "summary": "Find an invoice by DMS GUID",
        "x-required-permissions": [
          "invoices.read"
        ],
        "description": "Returns the invoice that belongs to a document of the document management system (`invoiceId` and `status`). The leading system uses it to find the invoice for an approval in its own workflow, so that it can call `submitExternalDecision`. An unknown GUID, an invoice of another company and an invoice in the trash all answer 404.",
        "parameters": [
          {
            "name": "guid",
            "in": "path",
            "required": true,
            "description": "GUID of the document in the document management system, as handed over in `dmsGuid`. GUID-shaped values are normalized to the ELO notation, so notation differences (braces, case) do not matter.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice of this document.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceByDmsGuid"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No invoice for this GUID in the company of the key (`invoice.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/integration/dms-transfers/next": {
      "post": {
        "tags": [
          "Integration"
        ],
        "operationId": "nextDmsTransfer",
        "summary": "Fetch the next document for the document management system",
        "x-required-permissions": [
          "invoices.upload"
        ],
        "description": "For companies with \"Hand documents over to ELO\": returns the next document that arrived in fineelik itself (web app, mobile app, mailbox address, API) and has no DMS GUID yet, oldest first. Documents from the document management system, sample invoices and invoices in the trash are never returned, and only documents from the moment the setting was switched on count.\n\n**Every fetch is an attempt.** The returned document is not offered again before its next attempt (5 minutes, 15 minutes, 1 hour, then every 6 hours), so the following documents keep moving if one fails. Fetch the file with `getInvoicePdf`, store it, then call `reportDmsTransfer` with the GUID or the reason.\n\nA key sees only documents of its own company.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DmsTransferNextRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The next document, or `item: null`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DmsTransferNextResponse"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid, for example `invoiceId` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.upload`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/integration/dms-transfers/{invoiceId}": {
      "post": {
        "tags": [
          "Integration"
        ],
        "operationId": "reportDmsTransfer",
        "summary": "Report the stored document",
        "x-required-permissions": [
          "invoices.upload"
        ],
        "description": "Reports the GUID of the new document in the document management system (`dmsGuid`) or the reason why it was not stored (`error`). With a GUID, fineelik sets it on the invoice exactly once, notes it in the history and writes an `invoice.export_changed` event, so that the next sync writes the state of the invoice into the new document. Repeating the same GUID changes nothing (`repeated`).\n\nWith a reason, fineelik shows it on the invoice and offers the document again at its next attempt.",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "description": "Id of the invoice from `nextDmsTransfer`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DmsTransferReportRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The report was recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DmsTransferReportResponse"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid: neither `dmsGuid` nor `error`, or both.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `invoices.upload`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The invoice does not exist or lies outside the company of the key (`invoice.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "The GUID already belongs to another invoice (`dms_transfer.guid_taken`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/integration/agreements/{externalGuid}": {
      "get": {
        "tags": [
          "Contracts"
        ],
        "operationId": "getEloAgreement",
        "summary": "Get the state of a contract managed in ELO",
        "x-required-permissions": [
          "agreements.integration_read"
        ],
        "description": "Returns the state of the contract with the fineelik fields and whether its matching conditions are approved in fineelik (see `AgreementEloState`). A key reads only contracts of its own company; an unknown GUID and a contract of another company answer 404.",
        "parameters": [
          {
            "name": "externalGuid",
            "in": "path",
            "required": true,
            "description": "GUID of the contract in ELO (`Sord.guid`). GUID-shaped values are normalized to the ELO notation, so braces and case do not matter.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The state of the contract.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgreementEloState"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `agreements.integration_read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No contract with this GUID in the company of the key (`agreement.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Contracts"
        ],
        "operationId": "putEloAgreement",
        "summary": "Hand over a contract from ELO",
        "x-required-permissions": [
          "agreements.integration_write"
        ],
        "description": "Creates or updates a contract that is managed in ELO Contract. ELO leads the contract: in fineelik its ELO fields (master data, partner as printed, term, termination, status, currency, total value, payments) are read only and change only through this route. fineelik keeps what ELO does not know (vendor, net or gross, tolerances, automatic approval, object numbers, keywords, confidentiality) and never overwrites it here.\n\n**Idempotent.** The GUID is unique. Sending the same payload again changes nothing and triggers nothing (`outcome` `unchanged`). A payload with an older `changedAt` than the stored one is not applied (`outcome` `stale`). Two hand overs of the same contract at the same time are serialized.\n\n**Approval in fineelik.** When the hand over changes the matching conditions (partner, term, currency, payments), the automatic approval of invoices rests until the conditions are approved again in fineelik. A running approval is withdrawn when the new state differs from the submitted one. The responsible persons get a notice and the event `agreement.conditions_changed` follows.\n\n**Status.** The status comes only from ELO; fineelik does not change it on its own and sends no own reminders for these contracts.",
        "parameters": [
          {
            "name": "externalGuid",
            "in": "path",
            "required": true,
            "description": "GUID of the contract in ELO (`Sord.guid`). GUID-shaped values are normalized to the ELO notation, so braces and case do not matter.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgreementEloHandover"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The result of the hand over.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgreementEloHandoverResponse"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid, for example a date or amount in the wrong format, a negative amount or more than two decimals.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `agreements.integration_write`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The company is not the one of the key or does not exist (`company.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflict: the contract belongs to another company in fineelik (`agreement_elo.company_mismatch`) or is managed in fineelik (`agreement_elo.not_elo_managed`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "Not applicable: unknown status key (`agreement_elo.unknown_status`, `params.value`) or no company given for a caller with several companies (`agreement_elo.company_required`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/integration/agreements/{externalGuid}/documents": {
      "post": {
        "tags": [
          "Contracts"
        ],
        "operationId": "addEloAgreementDocument",
        "summary": "Hand over a contract document from ELO",
        "x-required-permissions": [
          "agreements.integration_write"
        ],
        "description": "Attaches the contract document (PDF) from ELO to the contract, for display and for the reading by AI of the fineelik suggestions (keywords). Idempotent by `dmsGuid` and the hash of the file: the same document again answers `created` `false`. It does not start a reading by AI on its own.",
        "parameters": [
          {
            "name": "externalGuid",
            "in": "path",
            "required": true,
            "description": "GUID of the contract in ELO (`Sord.guid`). GUID-shaped values are normalized to the ELO notation, so braces and case do not matter.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "dmsGuid"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The contract document as a PDF file."
                  },
                  "dmsGuid": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "GUID of the document in ELO. Together with the hash of the file the anchor for idempotency."
                  },
                  "dmsVersion": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "Version of the document in ELO, kept as a note."
                  },
                  "role": {
                    "default": "main",
                    "type": "string",
                    "enum": [
                      "main",
                      "amendment",
                      "termination",
                      "other"
                    ],
                    "description": "Role of the document at the contract: `main` (default), `amendment`, `termination` or `other`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The document at the contract.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgreementEloDocumentResponse"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or invalid, for example `dmsGuid`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, invalid, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The owner of the API key does not hold the permission `agreements.integration_write`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No contract with this GUID in the company of the key, or no file in the field `file`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "The file is not a PDF (`agreement.document_type`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhooks",
        "summary": "List webhooks",
        "x-required-permissions": [
          "settings.read"
        ],
        "security": [
          {
            "SessionCookie": []
          }
        ],
        "description": "Lists the webhooks that the signed-in user may see: those whose scope the user's company access covers completely. The address is masked and each entry shows the delivery state (`cursor`, `pendingEvents`, `lastDeliveryAt`, `lastDeliveryOk`, `lastError`, `failingSince`).",
        "responses": {
          "200": {
            "description": "The webhooks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookList"
                }
              }
            }
          },
          "401": {
            "description": "Not signed in, or the session has ended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The signed-in user lacks the permission `settings.read`, or the call used an API key (API keys cannot use webhook routes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "createWebhook",
        "summary": "Create a webhook",
        "x-required-permissions": [
          "settings.manage"
        ],
        "security": [
          {
            "SessionCookie": []
          }
        ],
        "description": "Creates a webhook. The answer contains the signing secret, which appears only here and never again. A new webhook starts at the current end of the event stream and does not deliver past events.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The webhook was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateWebhookResponse"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid, or the address is refused (`webhook.url_invalid`, `webhook.url_not_https`, `webhook.url_credentials`, `webhook.url_masked`, `webhook.url_blocked`), or the account has no company that a webhook could deliver for (`webhook.no_company_scope`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Not signed in, or the session has ended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The signed-in user lacks the permission `settings.manage`, or the call used an API key (API keys cannot use webhook routes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The company does not exist or is outside the access (`company.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/webhooks/{id}": {
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "updateWebhook",
        "summary": "Change a webhook",
        "x-required-permissions": [
          "settings.manage"
        ],
        "security": [
          {
            "SessionCookie": []
          }
        ],
        "description": "Changes the given fields of a webhook; at least one is required. Send a changed address always complete: an address that contains `***` (the masked form) is refused with 400 `webhook.url_masked`. Changes apply immediately.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the webhook.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebhookRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The changed webhook.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid or the address is refused (`webhook.url_invalid`, `webhook.url_not_https`, `webhook.url_credentials`, `webhook.url_masked`, `webhook.url_blocked`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Not signed in, or the session has ended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The signed-in user lacks the permission `settings.manage`, or the call used an API key (API keys cannot use webhook routes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The webhook does not exist or is outside the access (`webhook.not_found`), or the company does not exist (`company.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "deleteWebhook",
        "summary": "Delete a webhook",
        "x-required-permissions": [
          "settings.manage"
        ],
        "security": [
          {
            "SessionCookie": []
          }
        ],
        "description": "Deletes the webhook together with its delivery log. The answer is the list of webhooks after the deletion.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the webhook.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The webhooks that remain.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookList"
                }
              }
            }
          },
          "400": {
            "description": "The id is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Not signed in, or the session has ended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The signed-in user lacks the permission `settings.manage`, or the call used an API key (API keys cannot use webhook routes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The webhook does not exist or is outside the access (`webhook.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/webhooks/{id}/rotate-secret": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "rotateWebhookSecret",
        "summary": "Renew the secret of a webhook",
        "x-required-permissions": [
          "settings.manage"
        ],
        "security": [
          {
            "SessionCookie": []
          }
        ],
        "description": "Creates a new signing secret. With an empty body or `{}` fineelik generates it, with `{ \"secret\": \"...\" }` the given one applies. The new secret appears only in this answer. From now on only the new secret is valid.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the webhook.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RotateWebhookSecretRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new secret.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RotateWebhookSecretResponse"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid, for example a secret that is too short.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Not signed in, or the session has ended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The signed-in user lacks the permission `settings.manage`, or the call used an API key (API keys cannot use webhook routes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The webhook does not exist or is outside the access (`webhook.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/webhooks/{id}/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "testWebhook",
        "summary": "Send a test call to a webhook",
        "x-required-permissions": [
          "settings.manage"
        ],
        "security": [
          {
            "SessionCookie": []
          }
        ],
        "description": "Sends a `ping` event (see `WebhookEvent`) to the address and returns the result at once. A test call changes neither the cursor nor the failure count and appears in the delivery log. At most one test call runs per webhook at a time, and at most 6 per minute are accepted; beyond that the answer is 429 `webhook.test_throttled`. A successful test call also triggers the next delivery attempt of a failing webhook.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the webhook.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The result of the call. A failed call is also answered with 200: look at `ok`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookTestResult"
                }
              }
            }
          },
          "400": {
            "description": "The secret of the webhook is not readable (`webhook.secret_unreadable`). Renew the secret.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Not signed in, or the session has ended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The signed-in user lacks the permission `settings.manage`, or the call used an API key (API keys cannot use webhook routes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The webhook does not exist or is outside the access (`webhook.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "description": "A test call is already running, or too many were sent (`webhook.test_throttled`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/webhooks/{id}/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhookDeliveries",
        "summary": "List the delivery log of a webhook",
        "x-required-permissions": [
          "settings.read"
        ],
        "security": [
          {
            "SessionCookie": []
          }
        ],
        "description": "Returns the delivery log of the webhook, newest first. Entries stay for 30 days. Entries about invoices appear only for companies within the access of the reader; test calls always appear.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the webhook.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Entries per page, 1 to 100. Default 25.",
            "schema": {
              "default": 25,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Number of entries to skip. Default 0.",
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of the delivery log.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveries"
                }
              }
            }
          },
          "400": {
            "description": "A parameter is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Not signed in, or the session has ended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "The signed-in user lacks the permission `settings.read`, or the call used an API key (API keys cannot use webhook routes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The webhook does not exist or is outside the access (`webhook.not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "API key from the settings of the web app (Settings, API keys, administrators only). A key can use only the permissions `invoices.upload`, `invoices.read`, `invoices.decide_external`, `agreements.integration_read` and `agreements.integration_write`, and only those its owner holds. It can be bound to one company and expires after one year at most."
      },
      "SessionCookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "better-auth.session_token",
        "description": "Session cookie of a signed-in user (the same session as in the web app; over HTTPS the cookie name carries the prefix `__Secure-`). Used for webhook management, which needs the permission `settings.manage` (change) or `settings.read` (read). API keys are refused on these routes."
      }
    },
    "schemas": {
      "ApiError": {
        "type": "object",
        "description": "Body of every error answer. `message` is plain text in German for people and logs: do not parse it. Rely on the HTTP status code and, where present, on `code` and `params`.",
        "required": [
          "statusCode",
          "message"
        ],
        "properties": {
          "statusCode": {
            "type": "integer",
            "description": "HTTP status code, repeated in the body."
          },
          "message": {
            "type": "string",
            "description": "Plain text in German. Not stable, do not parse it."
          },
          "error": {
            "type": "string",
            "description": "Name of the HTTP status, for example `Not Found`."
          },
          "code": {
            "type": "string",
            "description": "Stable error code where one is assigned, for example `approval.external_conflict`. Not every error carries a code; use the status code then."
          },
          "params": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Values that belong to the code, for example the `status` of an invoice."
          },
          "issues": {
            "type": "array",
            "description": "Only on 400 for an invalid request: one entry per invalid field. `path` names the field, `code` is the violated validation rule and `message` is a German explanation.",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string"
                },
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "retryAfterSeconds": {
            "type": "integer",
            "description": "Only on 429 from the rate limit: seconds until the next attempt, the same as the `Retry-After` header."
          }
        }
      },
      "Health": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "status"
        ],
        "description": "Health report of the instance. Further diagnostic fields may be added.",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "degraded"
            ],
            "description": "`ok` when database, queue and file storage work, otherwise `degraded`."
          },
          "checks": {
            "type": "object",
            "description": "Result of each check.",
            "properties": {
              "database": {
                "type": "boolean",
                "description": "The database answers."
              },
              "queue": {
                "type": "boolean",
                "description": "The job queue runs and no job has been waiting for too long."
              },
              "storage": {
                "type": "boolean",
                "description": "The file storage is writable."
              }
            }
          },
          "version": {
            "type": "string",
            "description": "Release of the running instance, or `dev` for a development build."
          },
          "uptimeSeconds": {
            "type": "integer",
            "description": "Seconds since the process started."
          }
        }
      },
      "UploadResponse": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the created invoice, or of the existing one when `duplicate` is `true`."
          },
          "status": {
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Status of the invoice. See \"Invoice status\" in the API introduction."
          },
          "duplicate": {
            "type": "boolean",
            "description": "`true` when the file or document was already known in this company. Then nothing new was created and the body names the existing invoice."
          }
        },
        "required": [
          "invoiceId",
          "status",
          "duplicate"
        ],
        "additionalProperties": false
      },
      "InvoiceList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceListItem"
            },
            "description": "The invoices of the requested page."
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Number of invoices that match the filters, across all pages."
          },
          "page": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Number of this page, starting at 1."
          },
          "pageSize": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Number of invoices per page."
          }
        },
        "required": [
          "items",
          "total",
          "page",
          "pageSize"
        ],
        "additionalProperties": false
      },
      "InvoiceListItem": {
        "type": "object",
        "properties": {
          "sourceFormat": {
            "default": "pdf",
            "type": "string",
            "enum": [
              "pdf",
              "image",
              "xrechnung",
              "zugferd",
              "facturx",
              "peppol",
              "en16931",
              "ebinterface",
              "eslog"
            ]
          },
          "sourceProfile": {
            "default": null,
            "nullable": true,
            "type": "string"
          },
          "isSample": {
            "default": false,
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice."
          },
          "companyId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the company the invoice belongs to."
          },
          "companyName": {
            "nullable": true,
            "type": "string",
            "description": "Name of the company."
          },
          "status": {
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Status of the invoice. See \"Invoice status\" in the API introduction."
          },
          "statusReason": {
            "nullable": true,
            "type": "string",
            "description": "Reason for the status, for example `approval_external`. See \"Invoice status\" in the API introduction."
          },
          "processing": {
            "nullable": true,
            "type": "object",
            "properties": {
              "step": {
                "type": "string",
                "enum": [
                  "preflight",
                  "ocr",
                  "extract",
                  "enrich",
                  "einvoice",
                  "suggest"
                ]
              },
              "state": {
                "type": "string",
                "enum": [
                  "queued",
                  "running",
                  "retrying",
                  "waiting",
                  "failed"
                ]
              },
              "error": {
                "nullable": true,
                "type": "string",
                "enum": [
                  "unavailable",
                  "timeout",
                  "rate_limited",
                  "quota",
                  "auth",
                  "config",
                  "document",
                  "ai_response",
                  "internal",
                  "license"
                ]
              },
              "retryAt": {
                "nullable": true,
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "startedAt": {
                "nullable": true,
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "since": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              }
            },
            "required": [
              "step",
              "state",
              "error",
              "retryAt",
              "startedAt",
              "since"
            ],
            "additionalProperties": false,
            "description": "Progress while the invoice is being processed (`captured`, `extracted`): step, state, kind of error and time of the next automatic attempt. `null` outside processing."
          },
          "needsClearance": {
            "default": false,
            "type": "boolean"
          },
          "clearanceNote": {
            "nullable": true,
            "type": "string"
          },
          "documentType": {
            "type": "string",
            "enum": [
              "invoice",
              "credit_note"
            ],
            "description": "`invoice` or `credit_note`."
          },
          "invoiceNumber": {
            "nullable": true,
            "type": "string",
            "description": "Invoice number as printed on the document."
          },
          "invoiceDate": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "Invoice date."
          },
          "dueDate": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "Due date."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "Currency of the document (ISO 4217)."
          },
          "netTotal": {
            "nullable": true,
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Net total as a decimal string."
          },
          "grossTotal": {
            "nullable": true,
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Gross total as a decimal string."
          },
          "vendorId": {
            "nullable": true,
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the matched vendor, if any."
          },
          "vendorName": {
            "nullable": true,
            "type": "string",
            "description": "Name of the matched vendor, if any."
          },
          "subVendorName": {
            "nullable": true,
            "type": "string"
          },
          "vendorMatchConfidence": {
            "nullable": true,
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "discountDueDate": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
          },
          "discountAmount": {
            "nullable": true,
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "paymentMethod": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "label": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "cash",
                  "credit_card",
                  "bank_transfer",
                  "private_outlay",
                  "direct_debit",
                  "debit_card",
                  "online"
                ]
              },
              "cardLast4": {
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "id",
              "label",
              "kind",
              "cardLast4"
            ],
            "additionalProperties": false
          },
          "deletedAt": {
            "nullable": true,
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "deletedByUserId": {
            "nullable": true,
            "type": "string"
          },
          "deletedByName": {
            "nullable": true,
            "type": "string"
          },
          "deletedFromStatus": {
            "nullable": true,
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ]
          },
          "deleteReason": {
            "nullable": true,
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When fineelik received the document."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When the invoice was last changed."
          }
        },
        "required": [
          "sourceFormat",
          "sourceProfile",
          "isSample",
          "id",
          "companyId",
          "status",
          "needsClearance",
          "documentType",
          "currency",
          "paymentMethod",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": false,
        "description": "One invoice in the list. `getInvoice` returns the full state."
      },
      "InvoiceDetail": {
        "type": "object",
        "properties": {
          "sourceFormat": {
            "default": "pdf",
            "type": "string",
            "enum": [
              "pdf",
              "image",
              "xrechnung",
              "zugferd",
              "facturx",
              "peppol",
              "en16931",
              "ebinterface",
              "eslog"
            ]
          },
          "sourceProfile": {
            "default": null,
            "nullable": true,
            "type": "string"
          },
          "isSample": {
            "default": false,
            "type": "boolean"
          },
          "intakeItem": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "status": {
                "type": "string",
                "enum": [
                  "open",
                  "assigned",
                  "done",
                  "processed"
                ]
              },
              "documentType": {
                "type": "string",
                "enum": [
                  "invoice",
                  "credit_note",
                  "delivery_note",
                  "order_confirmation",
                  "purchase_order",
                  "dunning",
                  "offer",
                  "contract",
                  "other",
                  "unknown",
                  "payment_receipt"
                ]
              },
              "assignedInvoice": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "invoiceNumber": {
                    "nullable": true,
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "invoiceNumber"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "id",
              "status",
              "documentType",
              "assignedInvoice"
            ],
            "additionalProperties": false
          },
          "tip": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "amount": {
                "type": "string"
              },
              "paidAmount": {
                "nullable": true,
                "type": "string"
              },
              "basis": {
                "type": "string",
                "enum": [
                  "printed",
                  "paid_difference"
                ]
              },
              "mode": {
                "type": "string",
                "enum": [
                  "off",
                  "notice",
                  "line"
                ]
              },
              "modeSource": {
                "type": "string",
                "enum": [
                  "sub_vendor",
                  "vendor",
                  "company"
                ]
              },
              "state": {
                "type": "string",
                "enum": [
                  "booked",
                  "open",
                  "above_limit",
                  "ignored"
                ]
              },
              "proposal": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string"
                  },
                  "taxRate": {
                    "type": "string"
                  },
                  "netAmount": {
                    "type": "string"
                  },
                  "taxAmount": {
                    "type": "string"
                  },
                  "grossAmount": {
                    "type": "string"
                  },
                  "dimensions": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "label": {
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "label"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "description",
                  "taxRate",
                  "netAmount",
                  "taxAmount",
                  "grossAmount",
                  "dimensions"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "amount",
              "paidAmount",
              "basis",
              "mode",
              "modeSource",
              "state",
              "proposal"
            ],
            "additionalProperties": false
          },
          "einvoiceReview": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "formalMode": {
                "type": "string",
                "enum": [
                  "hint",
                  "block"
                ]
              },
              "formalChecked": {
                "type": "boolean"
              },
              "formalValid": {
                "nullable": true,
                "type": "boolean"
              },
              "formalErrorCount": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "formalAcceptedAt": {
                "nullable": true,
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "formalAcceptedByName": {
                "nullable": true,
                "type": "string"
              },
              "formalBlocking": {
                "type": "boolean"
              },
              "prepaidAmount": {
                "nullable": true,
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d+)?$"
              },
              "prepaymentRecorded": {
                "type": "boolean"
              }
            },
            "required": [
              "formalMode",
              "formalChecked",
              "formalValid",
              "formalErrorCount",
              "formalAcceptedAt",
              "formalAcceptedByName",
              "formalBlocking",
              "prepaidAmount",
              "prepaymentRecorded"
            ],
            "additionalProperties": false
          },
          "matchReview": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "clearance",
                  "block"
                ]
              },
              "deviations": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "quantityDeviations": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "orderDeviations": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "confirmed": {
                "type": "boolean"
              },
              "confirmedAt": {
                "nullable": true,
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "confirmedByName": {
                "nullable": true,
                "type": "string"
              },
              "blocking": {
                "type": "boolean"
              }
            },
            "required": [
              "mode",
              "deviations",
              "quantityDeviations",
              "orderDeviations",
              "confirmed",
              "confirmedAt",
              "confirmedByName",
              "blocking"
            ],
            "additionalProperties": false
          },
          "agreementMatch": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "clearance",
                  "block"
                ]
              },
              "links": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "visibility": {
                      "type": "string",
                      "enum": [
                        "full",
                        "limited"
                      ]
                    },
                    "confidential": {
                      "type": "boolean"
                    },
                    "agreement": {
                      "nullable": true,
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        },
                        "number": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "vendorId": {
                          "nullable": true,
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        },
                        "vendorName": {
                          "nullable": true,
                          "type": "string"
                        },
                        "counterpartyName": {
                          "nullable": true,
                          "type": "string"
                        },
                        "managedBy": {
                          "default": "fineelik",
                          "type": "string",
                          "enum": [
                            "fineelik",
                            "elo"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "number",
                        "title",
                        "vendorId",
                        "vendorName",
                        "counterpartyName",
                        "managedBy"
                      ],
                      "additionalProperties": false
                    },
                    "paymentLine": {
                      "nullable": true,
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        },
                        "description": {
                          "type": "string"
                        },
                        "cycle": {
                          "type": "string",
                          "enum": [
                            "one_time",
                            "daily",
                            "weekly",
                            "biweekly",
                            "monthly",
                            "quarterly",
                            "half_yearly",
                            "yearly"
                          ]
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "fixed",
                            "variable"
                          ]
                        },
                        "objectNumber": {
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "description",
                        "cycle",
                        "kind",
                        "objectNumber"
                      ],
                      "additionalProperties": false
                    },
                    "matchSource": {
                      "type": "string",
                      "enum": [
                        "auto",
                        "suggested",
                        "manual"
                      ]
                    },
                    "matchRule": {
                      "type": "string",
                      "enum": [
                        "contract_number",
                        "match_key",
                        "object_number",
                        "score",
                        "manual"
                      ]
                    },
                    "matchedKey": {
                      "nullable": true,
                      "type": "string"
                    },
                    "score": {
                      "nullable": true,
                      "type": "number"
                    },
                    "reasons": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": "string",
                            "enum": [
                              "contract_number",
                              "match_key",
                              "object_number",
                              "vendor",
                              "amount_exact",
                              "amount_in_tolerance",
                              "amount_near",
                              "period_cycle",
                              "in_term",
                              "weak_key",
                              "several_candidates",
                              "vendor_mismatch",
                              "vendor_unknown"
                            ]
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string",
                                  "nullable": true,
                                  "enum": [
                                    null
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        "required": [
                          "code",
                          "params"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "periodStart": {
                      "nullable": true,
                      "type": "string",
                      "format": "date",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                    },
                    "periodEnd": {
                      "nullable": true,
                      "type": "string",
                      "format": "date",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                    },
                    "periodCount": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "amountBasis": {
                      "type": "string",
                      "enum": [
                        "net",
                        "gross"
                      ]
                    },
                    "currency": {
                      "type": "string"
                    },
                    "expectedAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                    },
                    "actualAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                    },
                    "deviationAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                    },
                    "deviationPercent": {
                      "nullable": true,
                      "type": "string"
                    },
                    "allowedUpAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                    },
                    "allowedDownAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                    },
                    "result": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "deviation",
                        "unchecked"
                      ]
                    },
                    "checks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": "string",
                            "enum": [
                              "amount_in_tolerance",
                              "amount_above",
                              "amount_below",
                              "amount_missing",
                              "no_payment_line",
                              "positions_unassigned",
                              "currency_mismatch",
                              "before_start",
                              "after_end",
                              "terminated",
                              "not_active",
                              "second_invoice_in_period",
                              "total_value_exceeded",
                              "total_value_near",
                              "variable_amount_unchecked",
                              "index_clause_present",
                              "price_increase",
                              "price_increase_over_limit"
                            ]
                          },
                          "severity": {
                            "type": "string",
                            "enum": [
                              "ok",
                              "info",
                              "deviation"
                            ]
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string",
                                  "nullable": true,
                                  "enum": [
                                    null
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        "required": [
                          "code",
                          "severity",
                          "params"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "positions": {
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      }
                    },
                    "confirmed": {
                      "type": "boolean"
                    },
                    "confirmedAt": {
                      "nullable": true,
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                    },
                    "confirmedByName": {
                      "nullable": true,
                      "type": "string"
                    },
                    "deviationAccepted": {
                      "type": "boolean"
                    },
                    "deviationAcceptedAt": {
                      "nullable": true,
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                    },
                    "deviationAcceptedByName": {
                      "nullable": true,
                      "type": "string"
                    },
                    "checkedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                    }
                  },
                  "required": [
                    "id",
                    "visibility",
                    "confidential",
                    "agreement",
                    "paymentLine",
                    "matchSource",
                    "matchRule",
                    "matchedKey",
                    "score",
                    "reasons",
                    "periodStart",
                    "periodEnd",
                    "periodCount",
                    "amountBasis",
                    "currency",
                    "expectedAmount",
                    "actualAmount",
                    "deviationAmount",
                    "deviationPercent",
                    "allowedUpAmount",
                    "allowedDownAmount",
                    "result",
                    "checks",
                    "positions",
                    "confirmed",
                    "confirmedAt",
                    "confirmedByName",
                    "deviationAccepted",
                    "deviationAcceptedAt",
                    "deviationAcceptedByName",
                    "checkedAt"
                  ],
                  "additionalProperties": false
                },
                "description": "Active assignments, also suggestions."
              },
              "deviations": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "blocking": {
                "type": "boolean",
                "description": "`true` when the company blocks on deviations and a deviation is not confirmed yet."
              },
              "outcome": {
                "type": "string",
                "enum": [
                  "ok",
                  "deviation",
                  "unchecked",
                  "suggested",
                  "partial",
                  "none"
                ],
                "description": "Result for the whole invoice: `ok`, `deviation`, `unchecked`, `suggested`, `partial` (not fully assigned) or `none`."
              },
              "autoApproval": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "possible": {
                    "type": "boolean"
                  },
                  "autoApproved": {
                    "type": "boolean"
                  },
                  "decidedAt": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  "outcome": {
                    "type": "string",
                    "enum": [
                      "ok",
                      "deviation",
                      "unchecked",
                      "suggested",
                      "partial",
                      "none"
                    ]
                  },
                  "blockers": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "module_not_licensed",
                        "company_auto_approve_off",
                        "match_failed",
                        "outcome_none",
                        "outcome_suggested",
                        "outcome_partial",
                        "outcome_unchecked",
                        "outcome_deviation",
                        "agreement_not_active",
                        "conditions_not_approved",
                        "conditions_pending",
                        "agreement_auto_approve_off",
                        "price_increase_over_limit",
                        "vendor_mismatch",
                        "amount_missing",
                        "max_amount_exceeded",
                        "first_invoice_of_vendor",
                        "bank_account_deviates",
                        "bank_account_recently_changed",
                        "duplicate_suspected",
                        "open_error_findings",
                        "credit_note",
                        "currency_mismatch",
                        "second_invoice_in_period",
                        "needs_clearance",
                        "order_match_deviation",
                        "sample_due"
                      ]
                    }
                  }
                },
                "required": [
                  "possible",
                  "autoApproved",
                  "decidedAt",
                  "outcome",
                  "blockers"
                ],
                "additionalProperties": false,
                "description": "Decision of the automatic approval when the approval started inside fineelik, or `null` when none was taken (before the start, without contract, or when the approval runs in the leading system).\n\n`blockers` lists the reasons against as codes, see `agreementMatch.blockers` in `InvoiceExport`."
              }
            },
            "required": [
              "mode",
              "links",
              "deviations",
              "blocking",
              "outcome",
              "autoApproval"
            ],
            "additionalProperties": false,
            "description": "Contract block (module \"Contracts\"): the assignments of the invoice to contracts and their check. `null` without the module.\n\nAn API key is never a named viewer: for a confidential contract an assignment has `visibility` `limited`, then contract, payment line, amounts, tolerance, score and the parameters of the checks are empty and only the result and the check codes remain."
          },
          "dmsTransfer": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "waiting",
                  "failed"
                ]
              },
              "attempts": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "lastError": {
                "nullable": true,
                "type": "string"
              },
              "nextAttemptAt": {
                "nullable": true,
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              }
            },
            "required": [
              "state",
              "attempts",
              "lastError",
              "nextAttemptAt"
            ],
            "additionalProperties": false
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice."
          },
          "status": {
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Status of the invoice. See \"Invoice status\" in the API introduction."
          },
          "statusReason": {
            "nullable": true,
            "type": "string",
            "description": "Reason for the status, for example `approval_external`. See \"Invoice status\" in the API introduction."
          },
          "processing": {
            "nullable": true,
            "type": "object",
            "properties": {
              "step": {
                "type": "string",
                "enum": [
                  "preflight",
                  "ocr",
                  "extract",
                  "enrich",
                  "einvoice",
                  "suggest"
                ]
              },
              "state": {
                "type": "string",
                "enum": [
                  "queued",
                  "running",
                  "retrying",
                  "waiting",
                  "failed"
                ]
              },
              "error": {
                "nullable": true,
                "type": "string",
                "enum": [
                  "unavailable",
                  "timeout",
                  "rate_limited",
                  "quota",
                  "auth",
                  "config",
                  "document",
                  "ai_response",
                  "internal",
                  "license"
                ]
              },
              "retryAt": {
                "nullable": true,
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "startedAt": {
                "nullable": true,
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "since": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              }
            },
            "required": [
              "step",
              "state",
              "error",
              "retryAt",
              "startedAt",
              "since"
            ],
            "additionalProperties": false,
            "description": "Progress while the invoice is being processed (`captured`, `extracted`): step, state (`queued`, `running`, `retrying`, `waiting`, `failed`), kind of error and time of the next automatic attempt. `null` outside processing."
          },
          "suggestionsPending": {
            "type": "boolean"
          },
          "pageRotation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 270
          },
          "captureChannel": {
            "type": "string",
            "enum": [
              "dms",
              "email",
              "upload",
              "api",
              "expense",
              "import",
              "reversal"
            ],
            "description": "Channel through which the document arrived (for example `upload` or `dms`)."
          },
          "externalDocumentLink": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "provider": {
                "type": "string",
                "enum": [
                  "elo"
                ]
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "provider",
              "url"
            ],
            "additionalProperties": false
          },
          "documentType": {
            "type": "string",
            "enum": [
              "invoice",
              "credit_note"
            ],
            "description": "`invoice` or `credit_note`."
          },
          "invoiceNumber": {
            "nullable": true,
            "type": "string",
            "description": "Invoice number as printed on the document."
          },
          "invoiceDate": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "Invoice date."
          },
          "dueDate": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "Due date."
          },
          "dueDateSource": {
            "nullable": true,
            "type": "string",
            "enum": [
              "extraction",
              "payment_term",
              "vendor_default",
              "invoice_date",
              "manual"
            ]
          },
          "paymentMethod": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "label": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "cash",
                  "credit_card",
                  "bank_transfer",
                  "private_outlay",
                  "direct_debit",
                  "debit_card",
                  "online"
                ]
              },
              "cardLast4": {
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "id",
              "label",
              "kind",
              "cardLast4"
            ],
            "additionalProperties": false
          },
          "paymentMethodSource": {
            "nullable": true,
            "type": "string",
            "enum": [
              "extraction",
              "vendor_default",
              "company_default",
              "manual"
            ]
          },
          "paymentHint": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "method": {
                "type": "string",
                "enum": [
                  "bank_transfer",
                  "direct_debit",
                  "credit_card",
                  "debit_card",
                  "online",
                  "cash",
                  "unknown"
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "open",
                  "paid",
                  "will_be_debited",
                  "unknown"
                ]
              },
              "cardLast4": {
                "nullable": true,
                "type": "string"
              },
              "evidence": {
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "method",
              "status",
              "cardLast4",
              "evidence"
            ],
            "additionalProperties": false
          },
          "paymentMethodWarnings": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "settled_but_transfer",
                "contradicts_vendor",
                "card_not_maintained"
              ]
            }
          },
          "servicePeriodStart": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "Start of the service period according to the document, if named."
          },
          "servicePeriodEnd": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "End of the service period according to the document, if named."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "Currency of the document (ISO 4217)."
          },
          "netTotal": {
            "nullable": true,
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Net total as a decimal string."
          },
          "grossTotal": {
            "nullable": true,
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Gross total as a decimal string."
          },
          "taxAmounts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "taxRate": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "netAmount": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "taxAmount": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                }
              },
              "required": [
                "taxRate",
                "netAmount",
                "taxAmount"
              ],
              "additionalProperties": false
            },
            "description": "Tax amounts by tax rate."
          },
          "reverseCharge": {
            "default": false,
            "type": "boolean"
          },
          "reverseChargeSource": {
            "default": "document",
            "type": "string",
            "enum": [
              "manual",
              "sub_vendor",
              "vendor",
              "group",
              "country",
              "document"
            ]
          },
          "reverseChargeInputs": {
            "default": {
              "override": "auto",
              "documentHint": false,
              "subVendorOverride": null,
              "vendorOverride": null,
              "vendorBusinessPostingGroup": null,
              "groupDefaults": {},
              "countryDefault": null
            },
            "type": "object",
            "properties": {
              "override": {
                "type": "string",
                "enum": [
                  "auto",
                  "ignore",
                  "force"
                ]
              },
              "documentHint": {
                "type": "boolean"
              },
              "subVendorOverride": {
                "nullable": true,
                "type": "string",
                "enum": [
                  "auto",
                  "ignore",
                  "force"
                ]
              },
              "vendorOverride": {
                "nullable": true,
                "type": "string",
                "enum": [
                  "auto",
                  "ignore",
                  "force"
                ]
              },
              "vendorBusinessPostingGroup": {
                "nullable": true,
                "type": "string"
              },
              "groupDefaults": {
                "type": "object",
                "additionalProperties": {
                  "type": "string",
                  "enum": [
                    "force",
                    "ignore"
                  ]
                }
              },
              "countryDefault": {
                "default": null,
                "nullable": true,
                "type": "boolean"
              }
            },
            "required": [
              "override",
              "documentHint",
              "subVendorOverride",
              "vendorOverride",
              "vendorBusinessPostingGroup",
              "groupDefaults",
              "countryDefault"
            ],
            "additionalProperties": false
          },
          "paymentTerms": {
            "nullable": true,
            "type": "object",
            "properties": {
              "dueDate": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "discountDays": {
                "nullable": true,
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "discountPercent": {
                "nullable": true,
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d+)?$"
              },
              "discountAmount": {
                "nullable": true,
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d+)?$"
              }
            },
            "additionalProperties": false,
            "description": "The payment term that fineelik applies (the best valid one)."
          },
          "paymentTermsList": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "rank": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991
                },
                "dueDate": {
                  "nullable": true,
                  "type": "string",
                  "format": "date",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                },
                "discountDays": {
                  "nullable": true,
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "discountPercent": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "discountAmount": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "extraction",
                    "manual",
                    "erp_default"
                  ]
                }
              },
              "required": [
                "rank",
                "discountPercent",
                "source"
              ],
              "additionalProperties": false
            }
          },
          "originalPaymentTerms": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "rank": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991
                },
                "dueDate": {
                  "nullable": true,
                  "type": "string",
                  "format": "date",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                },
                "discountDays": {
                  "nullable": true,
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "discountPercent": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "discountAmount": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                }
              },
              "required": [
                "rank",
                "discountPercent"
              ],
              "additionalProperties": false
            }
          },
          "orders": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "orderNumber": {
                  "type": "string"
                },
                "orderDate": {
                  "nullable": true,
                  "type": "string",
                  "format": "date",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                }
              },
              "required": [
                "orderNumber"
              ],
              "additionalProperties": false
            }
          },
          "company": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "code": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "vatId": {
                "nullable": true,
                "type": "string"
              },
              "defaultCurrency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "countryCode": {
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "id",
              "code",
              "name"
            ],
            "additionalProperties": false,
            "description": "The company the invoice belongs to."
          },
          "recipient": {
            "type": "object",
            "properties": {
              "name": {
                "nullable": true,
                "type": "string"
              },
              "vatId": {
                "nullable": true,
                "type": "string"
              },
              "taxNumber": {
                "default": null,
                "nullable": true,
                "type": "string"
              },
              "state": {
                "type": "string",
                "enum": [
                  "match",
                  "not_on_document",
                  "mismatch",
                  "other_company"
                ]
              },
              "taxNumberDiffers": {
                "default": null,
                "nullable": true,
                "type": "object",
                "properties": {
                  "printed": {
                    "type": "string"
                  },
                  "own": {
                    "type": "string"
                  }
                },
                "required": [
                  "printed",
                  "own"
                ],
                "additionalProperties": false
              },
              "suggestedCompany": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "name",
              "vatId",
              "taxNumber",
              "state",
              "taxNumberDiffers",
              "suggestedCompany"
            ],
            "additionalProperties": false
          },
          "vendor": {
            "nullable": true,
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "name": {
                "type": "string"
              },
              "vatId": {
                "nullable": true,
                "type": "string"
              },
              "matchType": {
                "nullable": true,
                "type": "string"
              },
              "matchConfidence": {
                "nullable": true,
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              "paymentDefaults": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "termDays": {
                    "nullable": true,
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "discountPercent": {
                    "nullable": true,
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                  },
                  "discountDays": {
                    "nullable": true,
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "id",
              "name"
            ],
            "additionalProperties": false,
            "description": "The matched vendor, if any."
          },
          "subVendor": {
            "nullable": true,
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "code": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "vatId": {
                "nullable": true,
                "type": "string"
              },
              "countryCode": {
                "nullable": true,
                "type": "string"
              },
              "city": {
                "nullable": true,
                "type": "string"
              },
              "hasIban": {
                "type": "boolean"
              }
            },
            "required": [
              "id",
              "code",
              "name",
              "hasIban"
            ],
            "additionalProperties": false
          },
          "collectiveSuggestion": {
            "nullable": true,
            "type": "object",
            "properties": {
              "vendorId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "vendorName": {
                "type": "string"
              },
              "scope": {
                "type": "string",
                "enum": [
                  "domestic",
                  "eu",
                  "non_eu",
                  "all"
                ]
              },
              "proposed": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "vatId": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 50
                  },
                  "countryCode": {
                    "nullable": true,
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2
                  },
                  "street": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 200
                  },
                  "zip": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 20
                  },
                  "city": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 100
                  },
                  "email": {
                    "nullable": true,
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "iban": {
                    "nullable": true,
                    "type": "string",
                    "minLength": 5,
                    "maxLength": 42,
                    "pattern": "^[A-Za-z]{2}[0-9A-Za-z ]+$"
                  },
                  "bic": {
                    "nullable": true,
                    "type": "string",
                    "pattern": "^[A-Za-z]{6}[0-9A-Za-z]{2}([0-9A-Za-z]{3})?$"
                  },
                  "reverseChargeOverride": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "ignore",
                      "force"
                    ]
                  },
                  "tipHandling": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "off",
                      "notice",
                      "line"
                    ]
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              },
              "existingSubVendorId": {
                "nullable": true,
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              }
            },
            "required": [
              "vendorId",
              "vendorName",
              "scope",
              "proposed"
            ],
            "additionalProperties": false
          },
          "ordererName": {
            "nullable": true,
            "type": "string"
          },
          "vendorPrinted": {
            "type": "object",
            "properties": {
              "name": {
                "nullable": true,
                "type": "string"
              },
              "vatId": {
                "nullable": true,
                "type": "string"
              },
              "taxNumber": {
                "nullable": true,
                "type": "string"
              },
              "street": {
                "nullable": true,
                "type": "string"
              },
              "zip": {
                "nullable": true,
                "type": "string"
              },
              "city": {
                "nullable": true,
                "type": "string"
              },
              "countryCode": {
                "nullable": true,
                "type": "string"
              },
              "bankAccounts": {
                "default": [],
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "iban": {
                      "type": "string"
                    },
                    "bic": {
                      "nullable": true,
                      "type": "string"
                    }
                  },
                  "required": [
                    "iban",
                    "bic"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "bankAccounts"
            ],
            "additionalProperties": false
          },
          "vendorCheck": {
            "nullable": true,
            "type": "object",
            "properties": {
              "subject": {
                "type": "string",
                "enum": [
                  "vendor",
                  "sub_vendor"
                ]
              },
              "subjectId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "vendorId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "ledByErp": {
                "type": "boolean"
              },
              "bankFromErp": {
                "type": "boolean"
              },
              "vendorIbanLast4": {
                "nullable": true,
                "type": "string"
              },
              "iban": {
                "type": "string",
                "enum": [
                  "match",
                  "unknown",
                  "vendor_without_iban",
                  "pending",
                  "none_printed"
                ]
              },
              "vatId": {
                "type": "string",
                "enum": [
                  "match",
                  "differs",
                  "vendor_without_vat_id",
                  "none_printed"
                ]
              },
              "name": {
                "type": "string",
                "enum": [
                  "match",
                  "differs"
                ]
              }
            },
            "required": [
              "subject",
              "subjectId",
              "vendorId",
              "ledByErp",
              "bankFromErp",
              "vendorIbanLast4",
              "iban",
              "vatId",
              "name"
            ],
            "additionalProperties": false
          },
          "lineItems": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "position": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "description": {
                  "type": "string"
                },
                "itemNo": {
                  "nullable": true,
                  "type": "string"
                },
                "quantity": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "unit": {
                  "nullable": true,
                  "type": "string"
                },
                "unitLabel": {
                  "nullable": true,
                  "type": "string"
                },
                "unitPrice": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "netAmount": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "taxRate": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "originalLineItemIds": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "isTip": {
                  "type": "boolean"
                },
                "dimensions": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string",
                        "minLength": 1
                      },
                      "label": {
                        "nullable": true,
                        "type": "string"
                      },
                      "source": {
                        "type": "string",
                        "enum": [
                          "manual",
                          "blueprint",
                          "extraction",
                          "default",
                          "mapping",
                          "suggestion"
                        ]
                      },
                      "confidence": {
                        "nullable": true,
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1
                      },
                      "note": {
                        "nullable": true,
                        "type": "string"
                      }
                    },
                    "required": [
                      "code",
                      "source"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "id",
                "position",
                "description",
                "netAmount",
                "taxRate",
                "originalLineItemIds",
                "dimensions"
              ],
              "additionalProperties": false
            },
            "description": "Line items with their account coding (the working state of the review)."
          },
          "headerDimensions": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "minLength": 1
                },
                "label": {
                  "nullable": true,
                  "type": "string"
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "manual",
                    "blueprint",
                    "extraction",
                    "default",
                    "mapping",
                    "suggestion"
                  ]
                },
                "confidence": {
                  "nullable": true,
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "note": {
                  "nullable": true,
                  "type": "string"
                }
              },
              "required": [
                "code",
                "source"
              ],
              "additionalProperties": false
            },
            "description": "Account coding on header level. The key is the dimension key, the value holds code and label."
          },
          "originalLineItems": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "position": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "itemNo": {
                  "nullable": true,
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "unit": {
                  "nullable": true,
                  "type": "string"
                },
                "unitPrice": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "netAmount": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "taxRate": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "appliedRule": {
                  "nullable": true,
                  "type": "object",
                  "properties": {
                    "blueprintId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "positionKey": {
                      "type": "string",
                      "minLength": 1
                    },
                    "groupId": {
                      "nullable": true,
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "bookingText": {
                      "nullable": true,
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "blueprintId",
                    "positionKey",
                    "groupId",
                    "bookingText",
                    "label"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "id",
                "position",
                "description"
              ],
              "additionalProperties": false
            }
          },
          "validation": {
            "type": "object",
            "properties": {
              "valid": {
                "type": "boolean"
              },
              "issues": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "minLength": 1
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "error",
                        "warning"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "field": {
                      "nullable": true,
                      "type": "string"
                    },
                    "lineNumber": {
                      "nullable": true,
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 9007199254740991
                    },
                    "dimensionKey": {
                      "nullable": true,
                      "type": "string"
                    },
                    "params": {
                      "nullable": true,
                      "type": "object",
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "number"
                          }
                        ]
                      }
                    }
                  },
                  "required": [
                    "code",
                    "severity",
                    "message"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "valid",
              "issues"
            ],
            "additionalProperties": false
          },
          "fieldConfidences": {
            "type": "object",
            "additionalProperties": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            }
          },
          "reviewedFields": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "invoiceNumber",
                "invoiceDate",
                "dueDate",
                "servicePeriodStart",
                "servicePeriodEnd",
                "currency",
                "documentType",
                "netTotal",
                "grossTotal",
                "vendorName",
                "vendorVatId",
                "vendorTaxNumber",
                "vendorStreet",
                "vendorZip",
                "vendorCity",
                "vendorCountryCode",
                "vendorIban",
                "paymentMethod"
              ]
            }
          },
          "blueprint": {
            "type": "object",
            "properties": {
              "applied": {
                "type": "boolean"
              },
              "blueprintId": {
                "nullable": true,
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "matchedRuleCount": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "suggestedLineItemIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                }
              },
              "ruleValues": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "lineItemId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "dimensionKey": {
                      "type": "string",
                      "minLength": 1
                    },
                    "code": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "lineItemId",
                    "dimensionKey",
                    "code"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "applied",
              "matchedRuleCount",
              "suggestedLineItemIds",
              "ruleValues"
            ],
            "additionalProperties": false
          },
          "duplicate": {
            "type": "object",
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "disabled",
                  "no_key",
                  "clear",
                  "dismissed",
                  "open"
                ]
              },
              "matchKind": {
                "nullable": true,
                "type": "string",
                "enum": [
                  "invoice_number",
                  "date_and_amount"
                ]
              },
              "key": {
                "nullable": true,
                "type": "string"
              },
              "dismissedAt": {
                "nullable": true,
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "original": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "invoiceNumber": {
                    "nullable": true,
                    "type": "string"
                  },
                  "invoiceDate": {
                    "nullable": true,
                    "type": "string",
                    "format": "date",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                  },
                  "grossAmount": {
                    "nullable": true,
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "captured",
                      "preflight_rejected",
                      "not_an_invoice",
                      "extracted",
                      "review_required",
                      "enriched",
                      "approval_pending",
                      "approved",
                      "rejected",
                      "payment_pending",
                      "payment_approved",
                      "paid",
                      "archived",
                      "duplicate",
                      "written_off",
                      "cancelled",
                      "deleted"
                    ]
                  },
                  "vendorName": {
                    "nullable": true,
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "state"
            ],
            "additionalProperties": false
          },
          "reversal": {
            "type": "object",
            "properties": {
              "reversalOf": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "invoiceNumber": {
                    "nullable": true,
                    "type": "string"
                  }
                },
                "required": [
                  "id"
                ],
                "additionalProperties": false
              },
              "reversedBy": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "invoiceNumber": {
                    "nullable": true,
                    "type": "string"
                  }
                },
                "required": [
                  "id"
                ],
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          "supersededAdvice": {
            "nullable": true,
            "type": "object",
            "properties": {
              "number": {
                "type": "string"
              },
              "sentAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              }
            },
            "required": [
              "number",
              "sentAt"
            ],
            "additionalProperties": false
          },
          "posting": {
            "nullable": true,
            "type": "object",
            "properties": {
              "documentNumber": {
                "nullable": true,
                "type": "string"
              },
              "postedAt": {
                "nullable": true,
                "type": "string"
              },
              "deviation": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "noticeId": {
                    "type": "string"
                  },
                  "readAt": {
                    "nullable": true,
                    "type": "string"
                  },
                  "payload": {
                    "type": "object",
                    "properties": {
                      "documentNumber": {
                        "type": "string"
                      },
                      "postedAt": {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      "accountNotComparable": {
                        "type": "boolean"
                      },
                      "deviations": {
                        "minItems": 1,
                        "type": "array",
                        "items": {
                          "oneOf": [
                            {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "header"
                                  ]
                                },
                                "field": {
                                  "type": "string",
                                  "enum": [
                                    "net",
                                    "tax",
                                    "gross",
                                    "currency"
                                  ]
                                },
                                "fineelik": {
                                  "nullable": true,
                                  "type": "string"
                                },
                                "bc": {
                                  "nullable": true,
                                  "type": "string"
                                }
                              },
                              "required": [
                                "kind",
                                "field",
                                "fineelik",
                                "bc"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "coding"
                                  ]
                                },
                                "values": {
                                  "type": "object",
                                  "additionalProperties": {
                                    "nullable": true,
                                    "type": "string"
                                  }
                                },
                                "taxRate": {
                                  "nullable": true,
                                  "type": "string"
                                },
                                "fineelik": {
                                  "nullable": true,
                                  "type": "string",
                                  "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                                },
                                "bc": {
                                  "nullable": true,
                                  "type": "string",
                                  "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                                }
                              },
                              "required": [
                                "kind",
                                "values",
                                "taxRate",
                                "fineelik",
                                "bc"
                              ],
                              "additionalProperties": false
                            }
                          ]
                        }
                      }
                    },
                    "required": [
                      "documentNumber",
                      "postedAt",
                      "accountNotComparable",
                      "deviations"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "noticeId",
                  "readAt",
                  "payload"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "documentNumber",
              "postedAt",
              "deviation"
            ],
            "additionalProperties": false
          },
          "deletedAt": {
            "nullable": true,
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "deletedByUserId": {
            "nullable": true,
            "type": "string"
          },
          "deletedByName": {
            "nullable": true,
            "type": "string"
          },
          "deletedFromStatus": {
            "nullable": true,
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ]
          },
          "deleteReason": {
            "nullable": true,
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When fineelik received the document."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When the invoice was last changed."
          }
        },
        "required": [
          "sourceFormat",
          "sourceProfile",
          "isSample",
          "intakeItem",
          "tip",
          "einvoiceReview",
          "matchReview",
          "agreementMatch",
          "dmsTransfer",
          "id",
          "status",
          "captureChannel",
          "externalDocumentLink",
          "documentType",
          "paymentMethod",
          "paymentHint",
          "paymentMethodWarnings",
          "currency",
          "taxAmounts",
          "reverseCharge",
          "reverseChargeSource",
          "reverseChargeInputs",
          "paymentTermsList",
          "originalPaymentTerms",
          "orders",
          "company",
          "recipient",
          "vendorPrinted",
          "lineItems",
          "headerDimensions",
          "originalLineItems",
          "validation",
          "fieldConfidences",
          "reviewedFields",
          "blueprint",
          "duplicate",
          "reversal",
          "supersededAdvice",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": false,
        "description": "The full state of an invoice: header and line data, account coding, approval and payment state, references (duplicate, reversal) and validation findings."
      },
      "InvoiceHistory": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                  "description": "Id of the entry."
                },
                "action": {
                  "type": "string",
                  "description": "Kind of change, for example `invoice.status_changed` or `invoice.line_items_replaced`."
                },
                "actorUserId": {
                  "nullable": true,
                  "type": "string",
                  "description": "Id of the user who acted. `null` when a machine acted."
                },
                "actorName": {
                  "nullable": true,
                  "type": "string",
                  "description": "Name of the user, if it can still be resolved."
                },
                "actorApiKeyId": {
                  "nullable": true,
                  "type": "string",
                  "description": "Id of the API key that acted. `null` when a user acted."
                },
                "before": {
                  "nullable": true,
                  "type": "object",
                  "additionalProperties": {},
                  "description": "State before the change. The keys depend on the action."
                },
                "after": {
                  "nullable": true,
                  "type": "object",
                  "additionalProperties": {},
                  "description": "State after the change. The keys depend on the action."
                },
                "metadata": {
                  "nullable": true,
                  "type": "object",
                  "additionalProperties": {},
                  "description": "Further details. For a decision reported from outside this holds `decidedBy`, `comment` and `externalRef`."
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
                  "description": "When the change happened."
                }
              },
              "required": [
                "id",
                "action",
                "actorUserId",
                "actorName",
                "actorApiKeyId",
                "before",
                "after",
                "metadata",
                "createdAt"
              ],
              "additionalProperties": false
            },
            "description": "History entries, newest first. At most the latest 200 entries are returned."
          }
        },
        "required": [
          "items"
        ],
        "additionalProperties": false
      },
      "ExternalDecisionRequest": {
        "type": "object",
        "properties": {
          "decision": {
            "type": "string",
            "enum": [
              "approved",
              "rejected"
            ],
            "description": "`approved` or `rejected`."
          },
          "decidedBy": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Name of the person who decided in the leading system (up to 200 characters). fineelik does not know this person as a user, the name is kept as plain text."
          },
          "comment": {
            "type": "string",
            "maxLength": 2000,
            "description": "Reason or note (up to 2000 characters)."
          },
          "externalRef": {
            "type": "string",
            "maxLength": 200,
            "description": "Reference of the leading system, for example a workflow id (up to 200 characters). Kept for the history only."
          }
        },
        "required": [
          "decision"
        ],
        "additionalProperties": false
      },
      "ExternalDecisionResponse": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice."
          },
          "status": {
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Status after the call: `approved` or `rejected`."
          },
          "applied": {
            "type": "boolean",
            "description": "`true`: the decision was applied now. `false`: the same decision was already on record and nothing changed."
          }
        },
        "required": [
          "invoiceId",
          "status",
          "applied"
        ],
        "additionalProperties": false
      },
      "IntegrationEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^\\d{1,19}$",
            "description": "Sequence number of the event, as a string. Unique and ascending. Use it as the cursor for the next call and to recognize an event that arrives twice."
          },
          "type": {
            "type": "string",
            "enum": [
              "invoice.received",
              "invoice.status_changed",
              "invoice.export_changed",
              "invoice.processing_failed"
            ],
            "description": "Kind of event:\n\n- `invoice.received`: the document was accepted (upload, e-mail or hand over from the document management system).\n- `invoice.status_changed`: every change of status, with `previousStatus`.\n- `invoice.export_changed`: data relevant for the export changed after review without a change of status, for example the account coding was corrected or the vendor changed.\n- `invoice.processing_failed`: processing (preflight, text recognition, extraction, matching) failed after the last automatic attempt, or waits for a missing setting. The status stays, `statusReason` is `<step>_failed: <text>`. Intermediate errors before another attempt (`<step>_retry`) create no event."
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When the event was created."
          },
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice."
          },
          "companyId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the company of the invoice."
          },
          "companyCode": {
            "type": "string",
            "description": "Code of the company."
          },
          "dmsGuid": {
            "nullable": true,
            "type": "string",
            "description": "GUID of the document in the document management system (for example ELO) when the invoice came from there, otherwise `null`."
          },
          "status": {
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Status of the invoice after the event."
          },
          "previousStatus": {
            "nullable": true,
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Only for `invoice.status_changed`: the status before. Otherwise `null`."
          },
          "statusReason": {
            "nullable": true,
            "type": "string",
            "description": "Reason for the status after the event, if any."
          },
          "agreementMatch": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "outcome": {
                "type": "string",
                "enum": [
                  "ok",
                  "deviation",
                  "unchecked",
                  "suggested",
                  "partial",
                  "none"
                ],
                "description": "Result for the whole invoice: `ok` (fully assigned, within the tolerance, nothing open), `deviation`, `unchecked` (an assignment could not be checked, for example without amount), `suggested` (only a suggestion, or an open suggestion beside the assignment), `partial` (not every position is assigned, or positions are assigned twice) or `none`."
              },
              "autoApprovalPossible": {
                "type": "boolean",
                "description": "`true` when every rule of the automatic approval holds, so `blockers` is empty."
              },
              "blockers": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "module_not_licensed",
                    "company_auto_approve_off",
                    "match_failed",
                    "outcome_none",
                    "outcome_suggested",
                    "outcome_partial",
                    "outcome_unchecked",
                    "outcome_deviation",
                    "agreement_not_active",
                    "conditions_not_approved",
                    "conditions_pending",
                    "agreement_auto_approve_off",
                    "price_increase_over_limit",
                    "vendor_mismatch",
                    "amount_missing",
                    "max_amount_exceeded",
                    "first_invoice_of_vendor",
                    "bank_account_deviates",
                    "bank_account_recently_changed",
                    "duplicate_suspected",
                    "open_error_findings",
                    "credit_note",
                    "currency_mismatch",
                    "second_invoice_in_period",
                    "needs_clearance",
                    "order_match_deviation",
                    "sample_due"
                  ]
                },
                "description": "Reasons against the automatic approval, as codes in a fixed order: `module_not_licensed`, `company_auto_approve_off`, `match_failed`, `outcome_none`, `outcome_suggested`, `outcome_partial`, `outcome_unchecked`, `outcome_deviation`, `agreement_not_active`, `conditions_not_approved`, `conditions_pending`, `agreement_auto_approve_off`, `vendor_mismatch`, `amount_missing`, `max_amount_exceeded`, `first_invoice_of_vendor`, `bank_account_deviates`, `bank_account_recently_changed`, `duplicate_suspected`, `open_error_findings`, `credit_note`, `currency_mismatch`, `second_invoice_in_period`, `needs_clearance`, `order_match_deviation`, `sample_due`. Treat unknown codes as a reason against."
              },
              "links": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "confidential": {
                      "type": "boolean",
                      "description": "`true` for a confidential contract. Then every field except `result` is `null`."
                    },
                    "agreementId": {
                      "nullable": true,
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "Id of the contract in fineelik."
                    },
                    "number": {
                      "nullable": true,
                      "type": "string",
                      "description": "Number of the contract in fineelik."
                    },
                    "externalNumber": {
                      "nullable": true,
                      "type": "string",
                      "description": "Number of the contract at the partner or in the leading system, or `null`."
                    },
                    "matchSource": {
                      "nullable": true,
                      "type": "string",
                      "enum": [
                        "auto",
                        "suggested",
                        "manual"
                      ],
                      "description": "`auto`, `suggested` (confirmed by a person) or `manual`."
                    },
                    "result": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "deviation",
                        "unchecked"
                      ],
                      "description": "Result of the check: `ok`, `deviation` or `unchecked`."
                    },
                    "currency": {
                      "nullable": true,
                      "type": "string",
                      "description": "Currency of the contract (ISO 4217)."
                    },
                    "expectedAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Expected amount for the period of the invoice (net or gross as set in the contract)."
                    },
                    "actualAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Actual amount of the invoice or of its assigned positions."
                    },
                    "deviationAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Actual minus expected amount (positive above the expected amount)."
                    },
                    "deviationPercent": {
                      "nullable": true,
                      "type": "string",
                      "description": "Deviation in percent of the expected amount, two decimals."
                    },
                    "allowedUpAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Allowed deviation upwards as an amount."
                    },
                    "allowedDownAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Allowed deviation downwards as an amount."
                    },
                    "externalGuid": {
                      "default": null,
                      "nullable": true,
                      "type": "string"
                    }
                  },
                  "required": [
                    "confidential",
                    "agreementId",
                    "number",
                    "externalNumber",
                    "matchSource",
                    "result",
                    "currency",
                    "expectedAmount",
                    "actualAmount",
                    "deviationAmount",
                    "deviationPercent",
                    "allowedUpAmount",
                    "allowedDownAmount",
                    "externalGuid"
                  ],
                  "additionalProperties": false
                },
                "description": "One entry per effective assignment (automatic, manual or confirmed)."
              }
            },
            "required": [
              "outcome",
              "autoApprovalPossible",
              "blockers",
              "links"
            ],
            "additionalProperties": false,
            "description": "Contract block (module \"Contracts\") as it is when the event is fetched or delivered, the same as `agreementMatch` in `InvoiceExport`. `null` without the module, without assignment, or when it could not be determined (then do not approve automatically).\n\nConfidential contracts: only `confidential` and `result` per entry, no number and no amounts."
          }
        },
        "required": [
          "id",
          "type",
          "occurredAt",
          "invoiceId",
          "companyId",
          "companyCode",
          "dmsGuid",
          "status",
          "previousStatus",
          "statusReason",
          "agreementMatch"
        ],
        "additionalProperties": false,
        "description": "One event about an invoice.",
        "example": {
          "id": "1842",
          "type": "invoice.status_changed",
          "occurredAt": "2026-09-28T10:15:02.113Z",
          "invoiceId": "018f4a52-7c1e-7b3a-9d2e-4f6a8b1c2d3e",
          "companyId": "018f4a52-1111-7b3a-9d2e-4f6a8b1c2d3e",
          "companyCode": "DEMO",
          "dmsGuid": null,
          "status": "approved",
          "previousStatus": "approval_pending",
          "statusReason": null,
          "agreementMatch": null
        }
      },
      "IntegrationEvents": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/IntegrationEvent"
                },
                {
                  "$ref": "#/components/schemas/AgreementIntegrationEvent"
                }
              ]
            },
            "description": "Events in ascending order of `id`."
          },
          "nextCursor": {
            "type": "string",
            "pattern": "^\\d{1,19}$",
            "description": "Id of the last event in this answer, or the `after` value of the call when nothing was found. Pass it as `after` in the next call."
          },
          "hasMore": {
            "type": "boolean",
            "description": "`true` when more events wait. Call again at once with `nextCursor`."
          }
        },
        "required": [
          "items",
          "nextCursor",
          "hasMore"
        ],
        "additionalProperties": false
      },
      "AgreementIntegrationEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^\\d{1,19}$",
            "description": "Sequence number of the event, as a string, from the same stream as the invoice events."
          },
          "type": {
            "type": "string",
            "enum": [
              "agreement.conditions_approved",
              "agreement.conditions_changed",
              "agreement.partner_assigned",
              "agreement.tags_changed",
              "agreement.auto_approve_changed"
            ],
            "description": "Kind of event (only for contracts managed in ELO):\n\n- `agreement.conditions_approved`: the matching conditions were approved in fineelik.\n- `agreement.conditions_changed`: the conditions changed (in fineelik or by a hand over from ELO), were submitted for approval, rejected or withdrawn; see `reason`.\n- `agreement.partner_assigned`: the partner was assigned to a vendor, or the assignment changed.\n- `agreement.tags_changed`: the keywords changed (`agreement.tagsText`).\n- `agreement.auto_approve_changed`: the switch for the automatic approval changed."
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "agreementId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the contract in fineelik."
          },
          "companyId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "companyCode": {
            "type": "string"
          },
          "externalSystem": {
            "nullable": true,
            "type": "string"
          },
          "externalGuid": {
            "nullable": true,
            "type": "string",
            "description": "GUID of the contract in ELO."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "in_negotiation",
              "in_approval",
              "approved",
              "signed",
              "active",
              "in_termination",
              "terminated",
              "ended"
            ],
            "description": "State of the contract in fineelik at the time of the event."
          },
          "reason": {
            "nullable": true,
            "type": "string",
            "description": "Occasion: `elo_handover`, `fineelik_edit`, `submitted`, `rejected`, `withdrawn`, `partner_mapping` or `extraction`; `null` for an approval."
          },
          "agreement": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AgreementEloState"
              }
            ],
            "nullable": true
          }
        },
        "required": [
          "id",
          "type",
          "occurredAt",
          "agreementId",
          "companyId",
          "companyCode",
          "externalSystem",
          "externalGuid",
          "status",
          "reason",
          "agreement"
        ],
        "additionalProperties": false,
        "description": "One event about a contract managed in ELO. `agreement` is the state when the event is fetched or delivered (see `AgreementEloState`), `null` when the contract no longer exists or the module is not licensed."
      },
      "AgreementEloState": {
        "type": "object",
        "properties": {
          "agreementId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the contract in fineelik."
          },
          "companyId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "companyCode": {
            "type": "string"
          },
          "number": {
            "type": "string",
            "description": "Number of the contract in fineelik."
          },
          "externalSystem": {
            "type": "string"
          },
          "externalGuid": {
            "type": "string",
            "description": "GUID of the contract in ELO (`Sord.guid`), in ELO notation."
          },
          "externalRevision": {
            "nullable": true,
            "type": "string",
            "description": "Revision of the last accepted hand over (as sent in `revision`)."
          },
          "externalChangedAt": {
            "nullable": true,
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "Time of change in ELO of the last accepted hand over."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "in_negotiation",
              "in_approval",
              "approved",
              "signed",
              "active",
              "in_termination",
              "terminated",
              "ended"
            ],
            "description": "State in fineelik, mapped from the status in ELO (`COMPLETED` is `active`). It comes only from ELO."
          },
          "eloStatus": {
            "nullable": true,
            "type": "string",
            "description": "Status key in ELO as sent, for example `COMPLETED`."
          },
          "confidential": {
            "type": "boolean"
          },
          "partner": {
            "nullable": true,
            "type": "object",
            "properties": {
              "externalKey": {
                "type": "string"
              },
              "name": {
                "nullable": true,
                "type": "string"
              },
              "assigned": {
                "type": "boolean"
              },
              "vendorId": {
                "nullable": true,
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "vendorName": {
                "nullable": true,
                "type": "string"
              },
              "erpVendorNumber": {
                "nullable": true,
                "type": "string"
              },
              "source": {
                "nullable": true,
                "type": "string",
                "enum": [
                  "auto",
                  "user"
                ]
              },
              "unresolvedReason": {
                "nullable": true,
                "type": "string",
                "enum": [
                  "none",
                  "ambiguous"
                ]
              }
            },
            "required": [
              "externalKey",
              "name",
              "assigned",
              "vendorId",
              "vendorName",
              "erpVendorNumber",
              "source",
              "unresolvedReason"
            ],
            "additionalProperties": false,
            "description": "Contract partner (first `PARTNER` of the hand over) and the vendor it is assigned to, or `null` without partner."
          },
          "amountBasis": {
            "type": "string",
            "enum": [
              "net",
              "gross"
            ]
          },
          "tolerance": {
            "type": "object",
            "properties": {
              "upPercent": {
                "nullable": true,
                "type": "string",
                "pattern": "^\\d{1,3}(\\.\\d{1,2})?$"
              },
              "downPercent": {
                "nullable": true,
                "type": "string",
                "pattern": "^\\d{1,3}(\\.\\d{1,2})?$"
              },
              "upAmount": {
                "nullable": true,
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d{1,2})?$"
              },
              "downAmount": {
                "nullable": true,
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d{1,2})?$"
              }
            },
            "required": [
              "upPercent",
              "downPercent",
              "upAmount",
              "downAmount"
            ],
            "additionalProperties": false
          },
          "autoApprove": {
            "type": "boolean"
          },
          "noPayments": {
            "type": "boolean"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Confirmed keywords of the contract (fineelik list), alphabetical."
          },
          "tagsText": {
            "type": "string",
            "description": "The same keywords as one text separated by `; `, for the text field in ELO."
          },
          "matchKeys": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Identifiers fineelik uses to assign invoices (number at the partner, customer number, object numbers)."
          },
          "responsible": {
            "nullable": true,
            "type": "object",
            "properties": {
              "userId": {
                "type": "string"
              },
              "email": {
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "userId",
              "email"
            ],
            "additionalProperties": false,
            "description": "Responsible person in fineelik with e-mail, or `null`."
          },
          "secondResponsible": {
            "nullable": true,
            "type": "object",
            "properties": {
              "userId": {
                "type": "string"
              },
              "email": {
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "userId",
              "email"
            ],
            "additionalProperties": false
          },
          "paymentLines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "externalKey": {
                  "nullable": true,
                  "type": "string"
                },
                "sequence": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "removed": {
                  "type": "boolean"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "fixed",
                    "variable"
                  ]
                },
                "objectNumber": {
                  "nullable": true,
                  "type": "string"
                },
                "tolerance": {
                  "type": "object",
                  "properties": {
                    "upPercent": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^\\d{1,3}(\\.\\d{1,2})?$"
                    },
                    "downPercent": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^\\d{1,3}(\\.\\d{1,2})?$"
                    },
                    "upAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                    },
                    "downAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                    }
                  },
                  "required": [
                    "upPercent",
                    "downPercent",
                    "upAmount",
                    "downAmount"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "externalKey",
                "sequence",
                "removed",
                "kind",
                "objectNumber",
                "tolerance"
              ],
              "additionalProperties": false
            },
            "description": "Payment lines with the fields that belong to fineelik, keyed by `externalKey` (the `lineKey` of the hand over, otherwise `pos:<n>`). `removed` lines were removed in ELO; they stay in fineelik because invoices refer to them."
          },
          "conditions": {
            "type": "object",
            "properties": {
              "approved": {
                "type": "boolean"
              },
              "pending": {
                "type": "boolean"
              },
              "everApproved": {
                "type": "boolean"
              },
              "approvedAt": {
                "nullable": true,
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "fingerprint": {
                "type": "string"
              },
              "approvedFingerprint": {
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "approved",
              "pending",
              "everApproved",
              "approvedAt",
              "fingerprint",
              "approvedFingerprint"
            ],
            "additionalProperties": false,
            "description": "Approval of the matching conditions in fineelik. Every change of a condition (also one from ELO: partner, term, currency, payments) needs a new approval in fineelik."
          },
          "automationReady": {
            "type": "boolean",
            "description": "See the description of the schema."
          },
          "automationBlockers": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "elo_not_active",
                "conditions_not_approved",
                "conditions_pending",
                "auto_approve_off",
                "company_auto_approve_off",
                "partner_unassigned"
              ]
            },
            "description": "Reasons at the contract against the automatic approval: `elo_not_active`, `conditions_not_approved`, `conditions_pending`, `auto_approve_off`, `company_auto_approve_off`, `partner_unassigned`. Treat unknown codes as a reason against."
          },
          "openPoints": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "partner_unassigned",
                "type_unknown",
                "conditions_not_approved",
                "payments_incomplete",
                "quota_reached"
              ]
            },
            "description": "Open points for people: `partner_unassigned`, `type_unknown` (mask without contract type), `conditions_not_approved`, `payments_incomplete` (a payment without amount or cycle), `quota_reached` (the contract quota of the instance is reached and this contract does not take up a place yet, so its conditions cannot be submitted)."
          }
        },
        "required": [
          "agreementId",
          "companyId",
          "companyCode",
          "number",
          "externalSystem",
          "externalGuid",
          "externalRevision",
          "externalChangedAt",
          "status",
          "eloStatus",
          "confidential",
          "partner",
          "amountBasis",
          "tolerance",
          "autoApprove",
          "noPayments",
          "tags",
          "tagsText",
          "matchKeys",
          "responsible",
          "secondResponsible",
          "paymentLines",
          "conditions",
          "automationReady",
          "automationBlockers",
          "openPoints"
        ],
        "additionalProperties": false,
        "description": "State of a contract that is managed in ELO Contract (module \"Contracts\"), for the leading system. It holds only what ELO has anyway (status, identifiers) and the fields that belong to fineelik: the vendor the partner is assigned to, net or gross, tolerances, automatic approval, object numbers, keywords, match keys and whether the matching conditions are approved in fineelik. No document content, no title and no summary, so the same applies to confidential contracts.\n\n`automationReady` is `true` when nothing at the contract speaks against the automatic approval of invoices (status in ELO `COMPLETED`, conditions approved in fineelik, switch on at the contract and in the company, partner assigned). The rules per invoice (bank account, duplicate, sample, ...) come on top and are in `agreementMatch` of the invoice."
      },
      "AgreementEloHandover": {
        "type": "object",
        "properties": {
          "companyId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Company in fineelik. A key is bound to one company; then leave it out (another value answers 404)."
          },
          "revision": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Revision of the contract in ELO, for example `Sord.tStamp`. Kept in the history."
          },
          "changedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
            "description": "Time of the change in ELO. A state older than the stored one is not applied (`outcome` `stale`)."
          },
          "maskKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Mask of the contract in ELO (`GENERAL_CONTRACT`, `PARTNER_CONTRACT`, `SERVICE_CONTRACT`, `LEASE_CONTRACT`, `SALES_CONTRACT` or a mask of the customer). It selects the contract type in fineelik; an unknown mask falls back to `GENERAL_CONTRACT` and is reported."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300,
            "description": "Short name of the contract (`Sord.name`), the title in fineelik."
          },
          "CONTRACT_DETAILS": {
            "type": "object",
            "properties": {
              "CONTRACT_STATUS": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "CONTRACT_NO": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_EXTERNAL_NO": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_TYPE": {
                "nullable": true,
                "type": "string",
                "maxLength": 200
              },
              "CONTRACT_TYPE_KEY": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_PHASE": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CURRENCY": {
                "nullable": true,
                "type": "string",
                "maxLength": 3
              },
              "BUSINESS_RELATION": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_RISK": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_DEPARTMENT": {
                "nullable": true,
                "type": "string",
                "maxLength": 200
              },
              "DESCRIPTION": {
                "nullable": true,
                "type": "string",
                "maxLength": 10000
              },
              "CONTRACT_RELATION": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_RESPONSIBLE": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "name": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 200
                  },
                  "email": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 320,
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  }
                }
              },
              "CONTRACT_PROCUREMENT": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "name": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 200
                  },
                  "email": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 320,
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  }
                }
              },
              "COUNTRY": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_APPLICABLE_LAW": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_PLACE_OF_EXECUTION": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_LANGUAGE": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "ORGANIZATION": {
                "nullable": true,
                "type": "string",
                "maxLength": 200
              }
            },
            "required": [
              "CONTRACT_STATUS"
            ],
            "additionalProperties": {},
            "description": "Aspect `ELO_CONTRACT.CONTRACT_DETAILS` with the ELO field names. `CONTRACT_STATUS` is required. Fields of type USER are objects with `email` (fineelik maps the person by e-mail) and `name`."
          },
          "CONTRACT_PERIOD": {
            "nullable": true,
            "type": "object",
            "properties": {
              "CONTRACT_START": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "CONTRACT_END": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "SIGNING_DATE": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "CONTRACT_DURATION": {
                "nullable": true,
                "type": "integer",
                "minimum": 0,
                "maximum": 1200
              },
              "CONTRACT_DURATION_UNIT": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_DURATION_TYPE": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_EXTENSION_TYPE": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "EXTENSION_BY_COUNT": {
                "nullable": true,
                "type": "integer",
                "minimum": 0,
                "maximum": 1200
              },
              "EXTENSION_UNIT": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "CONTRACT_END_AFTER_EXTENSION": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "ORIGINAL_CONTRACT_END": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "NEXT_CALC_DATE": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "CONTRACT_AUTO_CALCULATION": {
                "nullable": true,
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              }
            },
            "additionalProperties": {},
            "description": "Aspect `ELO_CONTRACT.CONTRACT_PERIOD` with the ELO field names."
          },
          "CONTRACT_TERMINATION": {
            "nullable": true,
            "type": "object",
            "properties": {
              "TERMINATION_PERIOD": {
                "nullable": true,
                "type": "integer",
                "minimum": 0,
                "maximum": 1200
              },
              "TERMINATION_PERIOD_UNIT": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "TERMINATION_EFFECTIVE_FROM": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "TERMINATION_TYPE": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "DEADLINE_TYPE": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "TERMINATION_DAY_OF_MONTH": {
                "nullable": true,
                "type": "integer",
                "minimum": 1,
                "maximum": 31
              },
              "TERMINATION_MANUAL_END": {
                "nullable": true,
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "TERMINATION_LAST_DATE": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "POSSIBLE_EFFECTIVE_DATE": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "TERMINATION_DATE": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "TERMINATION_EFFECTIVE_DATE": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "TERMINATION_CONTRACT_TYPE": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "TERMINATION_REASON": {
                "nullable": true,
                "type": "string",
                "maxLength": 2000
              },
              "TERMINATION_BY": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "name": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 200
                  },
                  "email": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 320,
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  }
                }
              },
              "EXTRAORDINARY_PERIOD": {
                "nullable": true,
                "type": "integer",
                "minimum": 0,
                "maximum": 1200
              },
              "EXTRAORDINARY_PERIOD_UNIT": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "EXTRAORDINARY_EFFECTIVE_FROM": {
                "nullable": true,
                "type": "string",
                "maxLength": 100
              },
              "EXTRAORDINARY_CONDITION": {
                "nullable": true,
                "type": "string",
                "maxLength": 2000
              },
              "EXTRAORDINARY_LAST_DATE": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              },
              "EXTRAORDINARY_EFFECTIVE_DATE": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              }
            },
            "additionalProperties": {},
            "description": "Aspect `ELO_CONTRACT.CONTRACT_TERMINATION` with the ELO field names."
          },
          "CONTRACT_VALUE": {
            "nullable": true,
            "type": "object",
            "properties": {
              "CURRENCY": {
                "nullable": true,
                "type": "string",
                "maxLength": 3
              },
              "CONTRACT_VALUE": {
                "nullable": true,
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d{1,2})?$"
              },
              "SUM_PERIODIC_PAYMENTS": {
                "nullable": true,
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d{1,2})?$"
              },
              "CONTRACT_END": {
                "nullable": true,
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
              }
            },
            "additionalProperties": {},
            "description": "Aspect `ELO_CONTRACT.CONTRACT_VALUE` with the ELO field names."
          },
          "CONTRACT_STATUS_INFO": {
            "nullable": true,
            "type": "object",
            "properties": {
              "MESSAGE": {
                "nullable": true,
                "type": "string",
                "maxLength": 2000
              },
              "SENDER": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "name": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 200
                  },
                  "email": {
                    "nullable": true,
                    "type": "string",
                    "maxLength": 320,
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  }
                }
              }
            },
            "additionalProperties": {},
            "description": "Aspect `ELO_CONTRACT.CONTRACT_STATUS_INFO`. Stored, not evaluated."
          },
          "PARTNER": {
            "default": [],
            "maxItems": 50,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "PARTNER": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "CONTACT_PERSON": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 200
                },
                "name": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 300
                },
                "vatId": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 40
                },
                "taxNumber": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 40
                },
                "creditorNumber": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 60
                },
                "ibans": {
                  "default": [],
                  "maxItems": 20,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40
                  }
                }
              },
              "required": [
                "PARTNER"
              ],
              "additionalProperties": {}
            },
            "description": "Aspect `ELO_CONTRACT.PARTNER`, 0 to n entries. The first one is the contract partner. `PARTNER` is the GUID of the contact in ELO and the key of the remembered assignment to a vendor. Send `name`, `vatId`, `taxNumber`, `creditorNumber` and `ibans` of the contact when you have them: fineelik assigns the vendor automatically by the remembered assignment, the creditor number, the VAT or tax number, the IBAN and last the exact name, and never guesses between several hits."
          },
          "PAYMENTS": {
            "default": [],
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lineKey": {
                  "nullable": true,
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                "PAYMENT_DESCRIPTION": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 300
                },
                "CYCLE": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 100
                },
                "SINGLE_AMOUNT": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                },
                "PAYMENT_START": {
                  "nullable": true,
                  "type": "string",
                  "format": "date",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                },
                "PAYMENT_END": {
                  "nullable": true,
                  "type": "string",
                  "format": "date",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                },
                "PAYMENT_SUM": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d{1,2})?$"
                },
                "PAYMENT_COUNT": {
                  "nullable": true,
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "DATE_TYPE": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 100
                },
                "REFERENCE_START_KEY": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 100
                },
                "REFERENCE_END_KEY": {
                  "nullable": true,
                  "type": "string",
                  "maxLength": 100
                }
              },
              "additionalProperties": {}
            },
            "description": "Aspect `ELO_CONTRACT.PAYMENTS`, 0 to n entries (`CYCLE` from `ELO_COMMON.TIME_INTERVAL`, `SINGLE_AMOUNT` as a decimal string). Send a stable `lineKey` per line when you have one, otherwise fineelik keys the lines by position. With `DATE_TYPE` `RELATIVE` send the resolved `PAYMENT_START` and `PAYMENT_END`. A line without amount or cycle is stored but not matched (warning `payment_incomplete`)."
          }
        },
        "required": [
          "revision",
          "changedAt",
          "maskKey",
          "name",
          "CONTRACT_DETAILS"
        ],
        "additionalProperties": false,
        "description": "Hand over of a contract from ELO Contract. Field names and list keys as in ELO; unknown fields of an aspect are stored without loss. Money as decimal strings with at most two decimals."
      },
      "AgreementEloHandoverResponse": {
        "type": "object",
        "properties": {
          "outcome": {
            "type": "string",
            "enum": [
              "created",
              "updated",
              "unchanged",
              "stale"
            ],
            "description": "`created`, `updated`, `unchanged` (the same payload as last time: nothing changed, nothing triggered) or `stale` (older than the stored state: nothing changed)."
          },
          "conditionsChanged": {
            "type": "boolean",
            "description": "`true` when the matching conditions changed: the automatic approval rests until the conditions are approved again in fineelik."
          },
          "approvalWithdrawn": {
            "type": "boolean",
            "description": "`true` when a running approval of the conditions in fineelik was withdrawn because the conditions changed. It has to be submitted again."
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "unknown_value",
                    "payment_incomplete",
                    "currency_conflict",
                    "type_unknown",
                    "extra_partners",
                    "partner_unassigned",
                    "user_unmatched"
                  ]
                },
                "field": {
                  "nullable": true,
                  "type": "string"
                },
                "value": {
                  "nullable": true,
                  "type": "string"
                }
              },
              "required": [
                "code",
                "field",
                "value"
              ],
              "additionalProperties": false
            },
            "description": "What was accepted but could not be mapped completely: `unknown_value`, `payment_incomplete`, `currency_conflict`, `type_unknown`, `extra_partners`, `partner_unassigned`, `user_unmatched`, each with the ELO field and value."
          },
          "state": {
            "$ref": "#/components/schemas/AgreementEloState"
          }
        },
        "required": [
          "outcome",
          "conditionsChanged",
          "approvalWithdrawn",
          "warnings",
          "state"
        ],
        "additionalProperties": false
      },
      "AgreementEloDocumentResponse": {
        "type": "object",
        "properties": {
          "agreementId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "documentId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "created": {
            "type": "boolean"
          }
        },
        "required": [
          "agreementId",
          "documentId",
          "created"
        ],
        "additionalProperties": false
      },
      "InvoiceByDmsGuid": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice in fineelik."
          },
          "status": {
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Status of the invoice. See \"Invoice status\" in the API introduction."
          }
        },
        "required": [
          "invoiceId",
          "status"
        ],
        "additionalProperties": false
      },
      "DmsTransferNextRequest": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          }
        },
        "additionalProperties": false
      },
      "DmsTransferItem": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice in fineelik. Fetch the file with `getInvoicePdf`."
          },
          "companyId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Company of the invoice."
          },
          "companyCode": {
            "type": "string",
            "description": "Code of the company."
          },
          "fileName": {
            "type": "string",
            "description": "Original file name, for the name of the document in the document management system."
          },
          "contentType": {
            "type": "string",
            "description": "`application/pdf`, or `application/xml` for an e-invoice."
          },
          "byteSize": {
            "nullable": true,
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Size of the file in bytes, if known."
          },
          "captureChannel": {
            "type": "string",
            "enum": [
              "upload",
              "email",
              "api"
            ],
            "description": "How the document arrived in fineelik: `upload` (web app and mobile app), `email` (mailbox address) or `api`."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When the document arrived in fineelik."
          },
          "attempt": {
            "type": "integer",
            "minimum": 0,
            "exclusiveMinimum": true,
            "maximum": 9007199254740991,
            "description": "Which fetch of this document this is (1 = first)."
          }
        },
        "required": [
          "invoiceId",
          "companyId",
          "companyCode",
          "fileName",
          "contentType",
          "byteSize",
          "captureChannel",
          "createdAt",
          "attempt"
        ],
        "additionalProperties": false
      },
      "DmsTransferNextResponse": {
        "type": "object",
        "properties": {
          "item": {
            "nullable": true,
            "type": "object",
            "properties": {
              "invoiceId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "companyId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "companyCode": {
                "type": "string"
              },
              "fileName": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "byteSize": {
                "nullable": true,
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "captureChannel": {
                "type": "string",
                "enum": [
                  "upload",
                  "email",
                  "api"
                ]
              },
              "createdAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "attempt": {
                "type": "integer",
                "minimum": 0,
                "exclusiveMinimum": true,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "invoiceId",
              "companyId",
              "companyCode",
              "fileName",
              "contentType",
              "byteSize",
              "captureChannel",
              "createdAt",
              "attempt"
            ],
            "additionalProperties": false,
            "description": "The next document for the document management system, or `null` if none is due."
          }
        },
        "required": [
          "item"
        ],
        "additionalProperties": false
      },
      "DmsTransferReportRequest": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "dmsGuid": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              }
            },
            "required": [
              "dmsGuid"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "minLength": 1,
                "maxLength": 4000
              }
            },
            "required": [
              "error"
            ],
            "additionalProperties": false
          }
        ]
      },
      "DmsTransferReportResponse": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice."
          },
          "result": {
            "type": "string",
            "enum": [
              "created",
              "repeated",
              "other_document",
              "failed"
            ],
            "description": "`created` (GUID set), `repeated` (the same GUID was already set), `other_document` (the invoice already belongs to another document, the reported one is a copy) or `failed` (reason stored, fineelik offers the document again later)."
          },
          "status": {
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Status of the invoice. See \"Invoice status\" in the API introduction."
          }
        },
        "required": [
          "invoiceId",
          "result",
          "status"
        ],
        "additionalProperties": false
      },
      "InvoiceExport": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice."
          },
          "revision": {
            "type": "string",
            "description": "Opaque fingerprint of the whole export. It changes with anything in the export, also with status, reason, review note (`reviewedAt`, `reviewedBy`), vendor and master data of the company."
          },
          "dataRevision": {
            "type": "string",
            "description": "Opaque fingerprint of only those invoice data that the receiver writes into its own invoice: `company.code`, `documentType`, `invoiceNumber`, `invoiceDate`, `deliveryDate`, `servicePeriodStart`, `servicePeriodEnd`, `dueDate`, `currency`, `netAmount`, `taxAmount`, `grossAmount`, `homeAmounts` (when present), `taxLines`, `paymentTerms`, `accounting` (header), `lines` with their `accounting` (also `deferral_code`) and `documentPositions`, `documentLines`, the explicit vendor assignment `vendor.id` (or `null`) and `paymentMethod.erpCode`, only when it is set. NOT covered: the other vendor master data under `vendor`, `company.id`, `company.name`, `company.vatId`, `invoiceId`, `dmsGuid`, `status`, `statusReason` and the review note. Write invoice data only when `dataRevision` is new. Then a pure status change, renaming a vendor or linking it to the ERP for the first time overwrites no correction made in the leading system. Take the vendor account (`vendor.erpVendorNumber`) over separately, on `invoice.export_changed` and only where it is still missing. A change of the assigned vendor (A to B) changes `dataRevision`."
          },
          "dmsGuid": {
            "nullable": true,
            "type": "string",
            "description": "GUID of the document in the document management system, or `null`."
          },
          "status": {
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Status of the invoice. See \"Invoice status\" in the API introduction."
          },
          "statusReason": {
            "nullable": true,
            "type": "string",
            "description": "Reason for the status, for example `approval_external`."
          },
          "company": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "description": "Id of the company."
              },
              "code": {
                "type": "string",
                "description": "Code of the company. The receiver uses it to select its own unit."
              },
              "name": {
                "type": "string",
                "description": "Name of the company."
              },
              "vatId": {
                "nullable": true,
                "type": "string",
                "description": "VAT id of the company, if known."
              }
            },
            "required": [
              "id",
              "code",
              "name",
              "vatId"
            ],
            "additionalProperties": false,
            "description": "The company the invoice belongs to."
          },
          "vendor": {
            "nullable": true,
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "description": "Id of the vendor in fineelik."
              },
              "name": {
                "type": "string",
                "description": "Name of the vendor."
              },
              "vatId": {
                "nullable": true,
                "type": "string",
                "description": "VAT id of the vendor, if known."
              },
              "countryCode": {
                "nullable": true,
                "type": "string",
                "description": "Country code of the vendor, if known."
              },
              "erpVendorNumber": {
                "nullable": true,
                "type": "string",
                "description": "Vendor account number in the ERP (Business Central \"No.\"), if linked."
              },
              "erpExternalId": {
                "nullable": true,
                "type": "string",
                "description": "Id in the ERP (Business Central SystemId), if linked."
              }
            },
            "required": [
              "id",
              "name",
              "vatId",
              "countryCode",
              "erpVendorNumber",
              "erpExternalId"
            ],
            "additionalProperties": false,
            "description": "The matched vendor, or `null` when none is assigned. For invoices of a sub-vendor this is the collective vendor."
          },
          "documentType": {
            "type": "string",
            "enum": [
              "invoice",
              "credit_note"
            ],
            "description": "`invoice` or `credit_note`."
          },
          "invoiceNumber": {
            "nullable": true,
            "type": "string",
            "description": "Invoice number as printed on the document."
          },
          "invoiceDate": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "Invoice date."
          },
          "deliveryDate": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "Delivery date."
          },
          "servicePeriodStart": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "Start of the service period according to the document, or `null`."
          },
          "servicePeriodEnd": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "End of the service period according to the document, or `null`."
          },
          "dueDate": {
            "nullable": true,
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
            "description": "Due date."
          },
          "currency": {
            "nullable": true,
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "Currency of the document (ISO 4217)."
          },
          "netAmount": {
            "nullable": true,
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Net amount as a decimal string."
          },
          "taxAmount": {
            "nullable": true,
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Tax amount as a decimal string."
          },
          "grossAmount": {
            "nullable": true,
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Gross amount as a decimal string."
          },
          "homeAmounts": {
            "nullable": true,
            "type": "object",
            "properties": {
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$",
                "description": "Home currency of the company."
              },
              "exchangeRate": {
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d+)?$",
                "description": "Units of the invoice currency per one unit of the home currency, as quoted by the ECB. For 1 EUR = 1.0832 USD this is `\"1.0832\"`. The home amount is the amount divided by the rate, rounded commercially to the decimals of the home currency."
              },
              "rateDate": {
                "type": "string",
                "format": "date",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
                "description": "Date of the rate."
              },
              "source": {
                "type": "string",
                "enum": [
                  "ECB",
                  "fixed"
                ],
                "description": "`ECB` for a rate of the European Central Bank, `fixed` for a fixed rate."
              },
              "netAmount": {
                "nullable": true,
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d+)?$",
                "description": "Net amount in the home currency, or `null`."
              },
              "grossAmount": {
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d+)?$",
                "description": "Gross amount in the home currency."
              }
            },
            "required": [
              "currency",
              "exchangeRate",
              "rateDate",
              "source",
              "netAmount",
              "grossAmount"
            ],
            "additionalProperties": false,
            "description": "Amounts in the home currency of the company at the rate of the invoice date. `null` for invoices in the home currency and while no rate is available (for example the invoice date or gross amount is missing, the date lies in the future, or the currency has no ECB rate)."
          },
          "taxLines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "taxRate": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Tax rate in percent."
                },
                "netAmount": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Net amount for this rate."
                },
                "taxAmount": {
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Tax amount for this rate."
                }
              },
              "required": [
                "taxRate",
                "netAmount",
                "taxAmount"
              ],
              "additionalProperties": false
            },
            "description": "Tax by tax rate."
          },
          "paymentTerms": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "rank": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "`1` is the term that fineelik applies (the best valid one)."
                },
                "dueDate": {
                  "nullable": true,
                  "type": "string",
                  "format": "date",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
                  "description": "Due date of this term, or `null`."
                },
                "days": {
                  "nullable": true,
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "Number of days of this term, or `null`."
                },
                "discountPercent": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Cash discount in percent, or `null`."
                },
                "discountAmount": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Cash discount amount, or `null`."
                }
              },
              "required": [
                "rank",
                "dueDate",
                "days",
                "discountPercent",
                "discountAmount"
              ],
              "additionalProperties": false
            },
            "description": "Payment terms of the invoice."
          },
          "paymentMethod": {
            "nullable": true,
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "cash",
                  "credit_card",
                  "bank_transfer",
                  "private_outlay",
                  "direct_debit",
                  "debit_card",
                  "online"
                ],
                "description": "Kind of payment method: `bank_transfer`, `direct_debit`, `credit_card`, `debit_card`, `online` or `cash`."
              },
              "label": {
                "type": "string",
                "description": "Name of the payment method."
              },
              "erpCode": {
                "nullable": true,
                "type": "string",
                "description": "Payment form code in the ERP (for example Business Central `Payment_Method_Code`), or `null`. See the notes of this schema."
              },
              "source": {
                "nullable": true,
                "type": "string",
                "enum": [
                  "extraction",
                  "vendor_default",
                  "company_default",
                  "manual"
                ],
                "description": "Where the payment method comes from: `extraction`, `vendor_default`, `company_default`, `manual` or `null`."
              }
            },
            "required": [
              "kind",
              "label",
              "erpCode",
              "source"
            ],
            "additionalProperties": false,
            "description": "Payment method of the invoice, or `null` when none is set. See the notes of this schema."
          },
          "accounting": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "label": {
                  "nullable": true,
                  "type": "string"
                }
              },
              "required": [
                "code",
                "label"
              ],
              "additionalProperties": false
            },
            "description": "Account coding on header level (for example the business posting groups) as dimensions. The key comes from the field catalog of the ERP adapter, the value holds `code` and `label`."
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lineNumber": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "Number of the booking line."
                },
                "documentPositions": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "description": "The `position` values of the document positions that this booking line combines. Empty when the line does not come from a document position."
                },
                "description": {
                  "type": "string",
                  "description": "Description of the line."
                },
                "quantity": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Quantity as a decimal string, or `null`."
                },
                "unit": {
                  "nullable": true,
                  "type": "string",
                  "description": "Code of a unit of the company (master data type `unitsOfMeasure`), or `null` when no unit is assigned. With Business Central it is the Business Central code (Code[10]). Without an ERP the standard units carry UN/ECE codes (Recommendation 20, package and unit from Recommendation 21 with a leading X), for example `H87` piece, `HUR` hour, `LS` lump sum, `KGM` kilogram; units created by hand keep their own code. The unit as printed is in `documentLines[].unit`. Documents from before the switch of 28 September 2026 can still carry the printed text here until someone picks the unit in review."
                },
                "unitPrice": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Unit price as a decimal string, or `null`."
                },
                "netAmount": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Net amount as a decimal string, or `null`."
                },
                "taxRate": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Tax rate in percent as a decimal string, or `null`."
                },
                "taxAmount": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Tax amount as a decimal string, or `null`."
                },
                "grossAmount": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Gross amount as a decimal string, or `null`."
                },
                "accounting": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string",
                        "description": "Code of the dimension value."
                      },
                      "label": {
                        "nullable": true,
                        "type": "string",
                        "description": "Designation of the dimension value, or `null`."
                      }
                    },
                    "required": [
                      "code",
                      "label"
                    ],
                    "additionalProperties": false
                  },
                  "description": "Account coding of the line as dimensions. The key comes from the field catalog of the ERP adapter (for example `general_ledger_account`, `cost_center`, `cost_bearer`, `general_product_posting_group`, `vat_product_posting_group`, `general_business_posting_group`, `vat_business_posting_group`, `booking_text`, `deferral_code` and further dimensions), the value holds `code` and `label`. Lines without deferral have no `deferral_code` key."
                }
              },
              "required": [
                "lineNumber",
                "documentPositions",
                "description",
                "quantity",
                "unit",
                "unitPrice",
                "netAmount",
                "taxRate",
                "taxAmount",
                "grossAmount",
                "accounting"
              ],
              "additionalProperties": false
            },
            "description": "Booking lines with their account coding. See the notes of this schema for how they relate to `documentLines`."
          },
          "documentLines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "position": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "Position on the document."
                },
                "description": {
                  "type": "string",
                  "description": "Description as printed."
                },
                "quantity": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Quantity as a decimal string, or `null`."
                },
                "unit": {
                  "nullable": true,
                  "type": "string",
                  "description": "Unit as printed. This is text, not a code."
                },
                "unitPrice": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Unit price in full precision as a decimal string, or `null`."
                },
                "netAmount": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Net amount with two decimals as a decimal string, or `null`."
                },
                "taxRate": {
                  "nullable": true,
                  "type": "string",
                  "pattern": "^-?\\d+(\\.\\d+)?$",
                  "description": "Tax rate with two decimals as a decimal string, or `null`."
                }
              },
              "required": [
                "position",
                "description",
                "quantity",
                "unit",
                "unitPrice",
                "netAmount",
                "taxRate"
              ],
              "additionalProperties": false
            },
            "description": "The positions as printed on the document (unchangeable state of the extraction), in ascending order of `position`."
          },
          "reviewedAt": {
            "nullable": true,
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When accounting finished the review in fineelik, or `null`."
          },
          "reviewedBy": {
            "nullable": true,
            "type": "string",
            "description": "Who finished the review in fineelik, or `null`."
          },
          "agreementMatch": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "outcome": {
                "type": "string",
                "enum": [
                  "ok",
                  "deviation",
                  "unchecked",
                  "suggested",
                  "partial",
                  "none"
                ],
                "description": "Result for the whole invoice: `ok` (fully assigned, within the tolerance, nothing open), `deviation`, `unchecked` (an assignment could not be checked, for example without amount), `suggested` (only a suggestion, or an open suggestion beside the assignment), `partial` (not every position is assigned, or positions are assigned twice) or `none`."
              },
              "autoApprovalPossible": {
                "type": "boolean",
                "description": "`true` when every rule of the automatic approval holds, so `blockers` is empty."
              },
              "blockers": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "module_not_licensed",
                    "company_auto_approve_off",
                    "match_failed",
                    "outcome_none",
                    "outcome_suggested",
                    "outcome_partial",
                    "outcome_unchecked",
                    "outcome_deviation",
                    "agreement_not_active",
                    "conditions_not_approved",
                    "conditions_pending",
                    "agreement_auto_approve_off",
                    "price_increase_over_limit",
                    "vendor_mismatch",
                    "amount_missing",
                    "max_amount_exceeded",
                    "first_invoice_of_vendor",
                    "bank_account_deviates",
                    "bank_account_recently_changed",
                    "duplicate_suspected",
                    "open_error_findings",
                    "credit_note",
                    "currency_mismatch",
                    "second_invoice_in_period",
                    "needs_clearance",
                    "order_match_deviation",
                    "sample_due"
                  ]
                },
                "description": "Reasons against the automatic approval, as codes in a fixed order: `module_not_licensed`, `company_auto_approve_off`, `match_failed`, `outcome_none`, `outcome_suggested`, `outcome_partial`, `outcome_unchecked`, `outcome_deviation`, `agreement_not_active`, `conditions_not_approved`, `conditions_pending`, `agreement_auto_approve_off`, `vendor_mismatch`, `amount_missing`, `max_amount_exceeded`, `first_invoice_of_vendor`, `bank_account_deviates`, `bank_account_recently_changed`, `duplicate_suspected`, `open_error_findings`, `credit_note`, `currency_mismatch`, `second_invoice_in_period`, `needs_clearance`, `order_match_deviation`, `sample_due`. Treat unknown codes as a reason against."
              },
              "links": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "confidential": {
                      "type": "boolean",
                      "description": "`true` for a confidential contract. Then every field except `result` is `null`."
                    },
                    "agreementId": {
                      "nullable": true,
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "Id of the contract in fineelik."
                    },
                    "number": {
                      "nullable": true,
                      "type": "string",
                      "description": "Number of the contract in fineelik."
                    },
                    "externalNumber": {
                      "nullable": true,
                      "type": "string",
                      "description": "Number of the contract at the partner or in the leading system, or `null`."
                    },
                    "matchSource": {
                      "nullable": true,
                      "type": "string",
                      "enum": [
                        "auto",
                        "suggested",
                        "manual"
                      ],
                      "description": "`auto`, `suggested` (confirmed by a person) or `manual`."
                    },
                    "result": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "deviation",
                        "unchecked"
                      ],
                      "description": "Result of the check: `ok`, `deviation` or `unchecked`."
                    },
                    "currency": {
                      "nullable": true,
                      "type": "string",
                      "description": "Currency of the contract (ISO 4217)."
                    },
                    "expectedAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Expected amount for the period of the invoice (net or gross as set in the contract)."
                    },
                    "actualAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Actual amount of the invoice or of its assigned positions."
                    },
                    "deviationAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Actual minus expected amount (positive above the expected amount)."
                    },
                    "deviationPercent": {
                      "nullable": true,
                      "type": "string",
                      "description": "Deviation in percent of the expected amount, two decimals."
                    },
                    "allowedUpAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Allowed deviation upwards as an amount."
                    },
                    "allowedDownAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Allowed deviation downwards as an amount."
                    },
                    "externalGuid": {
                      "default": null,
                      "nullable": true,
                      "type": "string"
                    }
                  },
                  "required": [
                    "confidential",
                    "agreementId",
                    "number",
                    "externalNumber",
                    "matchSource",
                    "result",
                    "currency",
                    "expectedAmount",
                    "actualAmount",
                    "deviationAmount",
                    "deviationPercent",
                    "allowedUpAmount",
                    "allowedDownAmount",
                    "externalGuid"
                  ],
                  "additionalProperties": false
                },
                "description": "One entry per effective assignment (automatic, manual or confirmed)."
              }
            },
            "required": [
              "outcome",
              "autoApprovalPossible",
              "blockers",
              "links"
            ],
            "additionalProperties": false,
            "description": "Contract block (module \"Contracts\"). `null` without the module or when the invoice is not assigned to a contract.\n\nIt carries the result of the contract check, one entry per effective assignment and whether fineelik would approve the invoice automatically (`autoApprovalPossible`) with the reasons against it (`blockers`), by the same rules as the automatic approval inside fineelik, without changing anything. A leading system that approves on its own (for example ELO) can skip its approval step when `autoApprovalPossible` is `true`.\n\nConfidential contracts: a machine is never a named viewer. For a confidential contract the entry holds only `confidential` and `result`; number, external number and all amounts of the contract are `null`."
          }
        },
        "required": [
          "invoiceId",
          "revision",
          "dataRevision",
          "dmsGuid",
          "status",
          "statusReason",
          "company",
          "vendor",
          "documentType",
          "invoiceNumber",
          "invoiceDate",
          "deliveryDate",
          "servicePeriodStart",
          "servicePeriodEnd",
          "dueDate",
          "currency",
          "netAmount",
          "taxAmount",
          "grossAmount",
          "homeAmounts",
          "taxLines",
          "paymentTerms",
          "paymentMethod",
          "accounting",
          "lines",
          "documentLines",
          "reviewedAt",
          "reviewedBy",
          "agreementMatch"
        ],
        "additionalProperties": false,
        "description": "Neutral export state of one invoice for the leading system. It contains no field names or ids of a specific system; mapping to the target system is the job of the receiver.\n\n**Payment method.** `paymentMethod` is `null` when none is set. `erpCode` is the payment form code in the ERP (Business Central `Payment_Method_Code`, Code[10]), stored on the payment method of the company. It is `null` while the invoice is before or in review (`captured`, `extracted`, `review_required`), when the payment method has no code, and when `source` is `company_default` or `null`. In these cases the ERP keeps the payment form of the vendor, and the default of the company overwrites nothing that the ERP keeps differently. The receiver writes only codes and never clears an existing value.\n\n**Collective vendors.** A collective vendor (a catch-all account such as \"Various vendors EU\") is an ordinary vendor account in the leading system. In fineelik it holds one-time vendors as sub-vendors. Their name, VAT id, address, e-mail and bank details live only in fineelik. The export always names the collective vendor under `vendor`, because only that one is known to the leading system. There is no block for the sub-vendor.\n\n**Booking lines and document positions.** `lines` are the booking lines as fineelik codes them (working state after template and review). One booking line can combine several positions of the document. `documentLines` are the positions as printed on the document: the unchangeable state of the extraction, in ascending order of `position`, including positions that belong to no booking line. `lines[].documentPositions` lists the `position` values of the document positions that a booking line combines (one each right after extraction). It is empty when the line does not come from a document position, for example when it was added in review. Documents without extracted positions (for example imported open items or invoices entered by hand) have `documentLines: []` and `documentPositions: []` in every line. The export always shows the current state: a new grouping in review changes only `documentPositions`; \"process again\" discards the document positions and reads them anew; reopening leaves them unchanged.\n\n**Service period and deferral.** `servicePeriodStart` and `servicePeriodEnd` are the service period according to the document (`YYYY-MM-DD` or `null`). A single service date appears as from = to. If the document names no period, both are `null`; the invoice date is never used as a substitute. The end is never before the start. The deferral of a line with a deferral code (`lines[].accounting.deferral_code`) starts at `servicePeriodStart`; the number of periods comes from the template in the ERP."
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the webhook."
          },
          "url": {
            "type": "string",
            "description": "Target address. Values of query parameters and a fragment are masked as `***`."
          },
          "urlHasSecret": {
            "type": "boolean",
            "description": "`true` when the address contains hidden values (query parameters or a fragment). To change the address, enter it completely again."
          },
          "description": {
            "nullable": true,
            "type": "string",
            "description": "Free text, up to 200 characters."
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "invoice.received",
                "invoice.status_changed",
                "invoice.export_changed",
                "invoice.processing_failed",
                "agreement.conditions_approved",
                "agreement.conditions_changed",
                "agreement.partner_assigned",
                "agreement.tags_changed",
                "agreement.auto_approve_changed"
              ]
            },
            "description": "The event types that are delivered."
          },
          "companyId": {
            "nullable": true,
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "The company the webhook is limited to. `null` means all companies the creator can see."
          },
          "companyName": {
            "nullable": true,
            "type": "string",
            "description": "Name of that company, or `null`."
          },
          "active": {
            "type": "boolean",
            "description": "`false` while the webhook is paused."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When the webhook was created."
          },
          "cursor": {
            "type": "string",
            "pattern": "^\\d{1,19}$",
            "description": "Number of the last event up to which everything that matches was delivered."
          },
          "pendingEvents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Number of events that still wait for delivery (with the current access of the creator)."
          },
          "lastDeliveryAt": {
            "nullable": true,
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "Time of the last delivery attempt, or `null`."
          },
          "lastDeliveryOk": {
            "nullable": true,
            "type": "boolean",
            "description": "Whether the last attempt succeeded, or `null`."
          },
          "lastError": {
            "nullable": true,
            "type": "string",
            "description": "Error of the last failed attempt (the address is masked), or `null`. `webhook.creator_no_access` when the creator has no access any more."
          },
          "failingSince": {
            "nullable": true,
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "Since when deliveries fail, or `null` while they work."
          }
        },
        "required": [
          "id",
          "url",
          "urlHasSecret",
          "description",
          "eventTypes",
          "companyId",
          "companyName",
          "active",
          "createdAt",
          "cursor",
          "pendingEvents",
          "lastDeliveryAt",
          "lastDeliveryOk",
          "lastError",
          "failingSince"
        ],
        "additionalProperties": false
      },
      "WebhookList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Webhook"
            },
            "description": "The webhooks."
          }
        },
        "required": [
          "items"
        ],
        "additionalProperties": false
      },
      "CreateWebhookRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 500,
            "format": "uri",
            "description": "Target address. https only, no credentials in the address, up to 500 characters. A token in the query part is allowed (ELO Flows) and appears only masked in answers."
          },
          "description": {
            "nullable": true,
            "type": "string",
            "maxLength": 200,
            "description": "Free text, up to 200 characters."
          },
          "eventTypes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "invoice.received",
                "invoice.status_changed",
                "invoice.export_changed",
                "invoice.processing_failed",
                "agreement.conditions_approved",
                "agreement.conditions_changed",
                "agreement.partner_assigned",
                "agreement.tags_changed",
                "agreement.auto_approve_changed"
              ]
            },
            "description": "At least one of `invoice.received`, `invoice.status_changed`, `invoice.export_changed`, `invoice.processing_failed`."
          },
          "companyId": {
            "nullable": true,
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Limit the webhook to one company (it must be within your access). Without it, all companies you can see at this moment."
          },
          "secret": {
            "type": "string",
            "minLength": 24,
            "maxLength": 200,
            "description": "Optional own secret (24 to 200 characters), for example the one entered in ELO Flows. Without it, fineelik generates one."
          }
        },
        "required": [
          "url",
          "eventTypes"
        ],
        "additionalProperties": false
      },
      "CreateWebhookResponse": {
        "type": "object",
        "properties": {
          "subscription": {
            "$ref": "#/components/schemas/Webhook"
          },
          "secret": {
            "type": "string",
            "description": "The signing secret. It appears only in this answer and in the answer to renewing, and never again."
          }
        },
        "required": [
          "subscription",
          "secret"
        ],
        "additionalProperties": false
      },
      "UpdateWebhookRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 500,
            "format": "uri",
            "description": "New target address, always complete. An address that contains `***` is refused with 400 `webhook.url_masked`."
          },
          "description": {
            "nullable": true,
            "type": "string",
            "maxLength": 200,
            "description": "Free text, up to 200 characters. `null` clears it."
          },
          "eventTypes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "invoice.received",
                "invoice.status_changed",
                "invoice.export_changed",
                "invoice.processing_failed",
                "agreement.conditions_approved",
                "agreement.conditions_changed",
                "agreement.partner_assigned",
                "agreement.tags_changed",
                "agreement.auto_approve_changed"
              ]
            },
            "description": "The event types to deliver, at least one."
          },
          "companyId": {
            "nullable": true,
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Limit to one company, or `null` for all companies you can see."
          },
          "active": {
            "type": "boolean",
            "description": "`false` pauses the webhook, `true` resumes it."
          }
        },
        "additionalProperties": false,
        "description": "Fields to change. At least one field is required."
      },
      "RotateWebhookSecretRequest": {
        "type": "object",
        "properties": {
          "secret": {
            "type": "string",
            "minLength": 24,
            "maxLength": 200,
            "description": "Optional own secret (24 to 200 characters). Without it, fineelik generates a new one."
          }
        },
        "additionalProperties": false
      },
      "RotateWebhookSecretResponse": {
        "type": "object",
        "properties": {
          "secret": {
            "type": "string",
            "description": "The new signing secret. It appears only in this answer. The old one is invalid now."
          }
        },
        "required": [
          "secret"
        ],
        "additionalProperties": false
      },
      "WebhookTestResult": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "description": "`true` when the target answered with a 2xx status."
          },
          "statusCode": {
            "nullable": true,
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "HTTP status of the answer, or `null` when there was none."
          },
          "error": {
            "nullable": true,
            "type": "string",
            "description": "Error text (the address is masked), or `null`."
          },
          "durationMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Duration of the call in milliseconds."
          }
        },
        "required": [
          "ok",
          "statusCode",
          "error",
          "durationMs"
        ],
        "additionalProperties": false
      },
      "WebhookDelivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the delivery attempt. The same value is sent in the header `X-Fineelik-Delivery`."
          },
          "eventId": {
            "nullable": true,
            "type": "string",
            "pattern": "^\\d{1,19}$",
            "description": "Number of the event, or `null` for a test call."
          },
          "eventType": {
            "type": "string",
            "description": "Type of the event (`ping` for a test call)."
          },
          "invoiceId": {
            "nullable": true,
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice, or `null` for a test call."
          },
          "attemptedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When the attempt was made."
          },
          "statusCode": {
            "nullable": true,
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "HTTP status of the answer, or `null` when there was none."
          },
          "ok": {
            "type": "boolean",
            "description": "`true` when the target answered with a 2xx status."
          },
          "error": {
            "nullable": true,
            "type": "string",
            "description": "Error text (the address is masked), or `null`."
          },
          "durationMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Duration of the call in milliseconds."
          }
        },
        "required": [
          "id",
          "eventId",
          "eventType",
          "invoiceId",
          "attemptedAt",
          "statusCode",
          "ok",
          "error",
          "durationMs"
        ],
        "additionalProperties": false,
        "description": "One delivery attempt in the log."
      },
      "WebhookDeliveries": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookDelivery"
            },
            "description": "Delivery attempts, newest first."
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Number of all entries, for paging."
          }
        },
        "required": [
          "items",
          "total"
        ],
        "additionalProperties": false
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^\\d{1,19}$",
            "description": "Sequence number of the event, as a string. Unique and ascending. Use it as the cursor for the next call and to recognize an event that arrives twice."
          },
          "type": {
            "type": "string",
            "enum": [
              "invoice.received",
              "invoice.status_changed",
              "invoice.export_changed",
              "invoice.processing_failed",
              "ping"
            ],
            "description": "Kind of event, see `IntegrationEvent`. `ping` appears only in test calls and carries no data. Events about contracts managed in ELO (`agreement.*`) arrive in the form `AgreementIntegrationEvent`. Acknowledge and ignore unknown types."
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "When the event was created."
          },
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the invoice."
          },
          "companyId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Id of the company of the invoice."
          },
          "companyCode": {
            "type": "string",
            "description": "Code of the company."
          },
          "dmsGuid": {
            "nullable": true,
            "type": "string",
            "description": "GUID of the document in the document management system (for example ELO) when the invoice came from there, otherwise `null`."
          },
          "status": {
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Status of the invoice after the event."
          },
          "previousStatus": {
            "nullable": true,
            "type": "string",
            "enum": [
              "captured",
              "preflight_rejected",
              "not_an_invoice",
              "extracted",
              "review_required",
              "enriched",
              "approval_pending",
              "approved",
              "rejected",
              "payment_pending",
              "payment_approved",
              "paid",
              "archived",
              "duplicate",
              "written_off",
              "cancelled",
              "deleted"
            ],
            "description": "Only for `invoice.status_changed`: the status before. Otherwise `null`."
          },
          "statusReason": {
            "nullable": true,
            "type": "string",
            "description": "Reason for the status after the event, if any."
          },
          "agreementMatch": {
            "default": null,
            "nullable": true,
            "type": "object",
            "properties": {
              "outcome": {
                "type": "string",
                "enum": [
                  "ok",
                  "deviation",
                  "unchecked",
                  "suggested",
                  "partial",
                  "none"
                ],
                "description": "Result for the whole invoice: `ok` (fully assigned, within the tolerance, nothing open), `deviation`, `unchecked` (an assignment could not be checked, for example without amount), `suggested` (only a suggestion, or an open suggestion beside the assignment), `partial` (not every position is assigned, or positions are assigned twice) or `none`."
              },
              "autoApprovalPossible": {
                "type": "boolean",
                "description": "`true` when every rule of the automatic approval holds, so `blockers` is empty."
              },
              "blockers": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "module_not_licensed",
                    "company_auto_approve_off",
                    "match_failed",
                    "outcome_none",
                    "outcome_suggested",
                    "outcome_partial",
                    "outcome_unchecked",
                    "outcome_deviation",
                    "agreement_not_active",
                    "conditions_not_approved",
                    "conditions_pending",
                    "agreement_auto_approve_off",
                    "price_increase_over_limit",
                    "vendor_mismatch",
                    "amount_missing",
                    "max_amount_exceeded",
                    "first_invoice_of_vendor",
                    "bank_account_deviates",
                    "bank_account_recently_changed",
                    "duplicate_suspected",
                    "open_error_findings",
                    "credit_note",
                    "currency_mismatch",
                    "second_invoice_in_period",
                    "needs_clearance",
                    "order_match_deviation",
                    "sample_due"
                  ]
                },
                "description": "Reasons against the automatic approval, as codes in a fixed order: `module_not_licensed`, `company_auto_approve_off`, `match_failed`, `outcome_none`, `outcome_suggested`, `outcome_partial`, `outcome_unchecked`, `outcome_deviation`, `agreement_not_active`, `conditions_not_approved`, `conditions_pending`, `agreement_auto_approve_off`, `vendor_mismatch`, `amount_missing`, `max_amount_exceeded`, `first_invoice_of_vendor`, `bank_account_deviates`, `bank_account_recently_changed`, `duplicate_suspected`, `open_error_findings`, `credit_note`, `currency_mismatch`, `second_invoice_in_period`, `needs_clearance`, `order_match_deviation`, `sample_due`. Treat unknown codes as a reason against."
              },
              "links": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "confidential": {
                      "type": "boolean",
                      "description": "`true` for a confidential contract. Then every field except `result` is `null`."
                    },
                    "agreementId": {
                      "nullable": true,
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "Id of the contract in fineelik."
                    },
                    "number": {
                      "nullable": true,
                      "type": "string",
                      "description": "Number of the contract in fineelik."
                    },
                    "externalNumber": {
                      "nullable": true,
                      "type": "string",
                      "description": "Number of the contract at the partner or in the leading system, or `null`."
                    },
                    "matchSource": {
                      "nullable": true,
                      "type": "string",
                      "enum": [
                        "auto",
                        "suggested",
                        "manual"
                      ],
                      "description": "`auto`, `suggested` (confirmed by a person) or `manual`."
                    },
                    "result": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "deviation",
                        "unchecked"
                      ],
                      "description": "Result of the check: `ok`, `deviation` or `unchecked`."
                    },
                    "currency": {
                      "nullable": true,
                      "type": "string",
                      "description": "Currency of the contract (ISO 4217)."
                    },
                    "expectedAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Expected amount for the period of the invoice (net or gross as set in the contract)."
                    },
                    "actualAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Actual amount of the invoice or of its assigned positions."
                    },
                    "deviationAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Actual minus expected amount (positive above the expected amount)."
                    },
                    "deviationPercent": {
                      "nullable": true,
                      "type": "string",
                      "description": "Deviation in percent of the expected amount, two decimals."
                    },
                    "allowedUpAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Allowed deviation upwards as an amount."
                    },
                    "allowedDownAmount": {
                      "nullable": true,
                      "type": "string",
                      "pattern": "^-?\\d+(\\.\\d{1,2})?$",
                      "description": "Allowed deviation downwards as an amount."
                    },
                    "externalGuid": {
                      "default": null,
                      "nullable": true,
                      "type": "string"
                    }
                  },
                  "required": [
                    "confidential",
                    "agreementId",
                    "number",
                    "externalNumber",
                    "matchSource",
                    "result",
                    "currency",
                    "expectedAmount",
                    "actualAmount",
                    "deviationAmount",
                    "deviationPercent",
                    "allowedUpAmount",
                    "allowedDownAmount",
                    "externalGuid"
                  ],
                  "additionalProperties": false
                },
                "description": "One entry per effective assignment (automatic, manual or confirmed)."
              }
            },
            "required": [
              "outcome",
              "autoApprovalPossible",
              "blockers",
              "links"
            ],
            "additionalProperties": false,
            "description": "Contract block (module \"Contracts\") as it is when the event is fetched or delivered, the same as `agreementMatch` in `InvoiceExport`. `null` without the module, without assignment, or when it could not be determined (then do not approve automatically).\n\nConfidential contracts: only `confidential` and `result` per entry, no number and no amounts."
          }
        },
        "required": [
          "id",
          "type",
          "occurredAt",
          "invoiceId",
          "companyId",
          "companyCode",
          "dmsGuid",
          "status",
          "previousStatus",
          "statusReason",
          "agreementMatch"
        ],
        "additionalProperties": false,
        "description": "The JSON body of a webhook delivery. It has the same shape as one entry of `listIntegrationEvents`. The only addition is the type `ping`, which appears in test calls (`testWebhook`) and means nothing: acknowledge unknown types with 2xx and ignore them.\n\nA test call uses `type` `ping`, `id` `\"0\"`, the invoice id `00000000-0000-0000-0000-000000000000` and the company of the webhook (the same zero UUID without a fixed company). It changes neither the cursor nor the failure count and appears in the delivery log.\n\n**Headers of the delivery**\n\n- `X-Fineelik-Signature`: `t=<unix seconds>,v1=<hex>` (signature with a timestamp, recommended).\n- `X-Hub-Signature`: `sha256=<hex>` (WebSub format, checked by ELO Flows itself).\n- `X-Fineelik-Event`: the event type (`ping` for a test call).\n- `X-Fineelik-Delivery`: id of this delivery attempt (it appears in the delivery log).\n- `User-Agent`: `fineelik-webhooks/1`.\n- `Content-Type`: `application/json`.\n\n**Verifying the signature.** fineelik sends both signatures with the same secret; check one of them. The key is the secret exactly as shown or given, including `whsec_` if present (UTF-8). `body` is the raw request body, byte for byte and before any JSON parsing. Compare in constant time.\n\n- `X-Fineelik-Signature`: `v1` is the hex HMAC-SHA256 of `<t>.<body>`, where `t` is the value from the header. Reject timestamps that are more than 5 minutes away from your own clock. This guards against replay.\n- `X-Hub-Signature`: `sha256=` followed by the hex HMAC-SHA256 of `<body>`, without a timestamp. Against replay use the event number `id`, which a receiver evaluates for \"at least once\" anyway.\n\nTest vector: secret `whsec_testgeheimnis`, `t` = `1700000000` and body `{\"id\":\"42\",\"type\":\"invoice.status_changed\"}` give `v1=d5f4a33b0c6510fdb99e15e5aa059c51cea8869e2fe7407b161a3e4c1d58f7df` and `X-Hub-Signature: sha256=21e78171381c266463b9c9ad85f8d0a92d55f7480ce503feb72ed982db8239c4`.",
        "example": {
          "id": "1842",
          "type": "invoice.status_changed",
          "occurredAt": "2026-09-28T10:15:02.113Z",
          "invoiceId": "018f4a52-7c1e-7b3a-9d2e-4f6a8b1c2d3e",
          "companyId": "018f4a52-1111-7b3a-9d2e-4f6a8b1c2d3e",
          "companyCode": "DEMO",
          "dmsGuid": null,
          "status": "approved",
          "previousStatus": "approval_pending",
          "statusReason": null,
          "agreementMatch": null
        }
      }
    }
  }
}
