> ## Documentation Index
> Fetch the complete documentation index at: https://docs.watchdog.no/llms.txt
> Use this file to discover all available pages before exploring further.

# Set an invoice's approval steps

> Replaces the invoice's approvers with these steps, last save wins. Steps set only the order: the invoice is approved once required_approvals of its approvers have approved, however many steps it has. One approval completes a step, and only then may the next step's approvers approve; once every step has an approval, any approver who has not approved may. Approvers not named are removed and new ones added, as updateInvoiceApprovers does and with its rules; those who stay move to the step they are named in. A step someone approved is locked: it keeps its approvers and its place; an approval recorded with one step stays in the first step. Approvers whose turn begins are asked. Recorded in the invoice's activity.



## OpenAPI

````yaml /openapi.json put /v1/invoices/{id}/approval-steps
openapi: 3.1.0
info:
  title: Watchdog API
  version: 1.0.0
  description: >-
    The Watchdog API is served from https://api.watchdog.no. Request bodies are
    limited to 2 MiB unless an endpoint says otherwise. Files are uploaded
    directly to storage, not through the API.
servers:
  - url: https://api.watchdog.no
    description: Watchdog API
security: []
paths:
  /v1/invoices/{id}/approval-steps:
    put:
      tags:
        - Invoices
      summary: Set an invoice's approval steps
      description: >-
        Replaces the invoice's approvers with these steps, last save wins. Steps
        set only the order: the invoice is approved once required_approvals of
        its approvers have approved, however many steps it has. One approval
        completes a step, and only then may the next step's approvers approve;
        once every step has an approval, any approver who has not approved may.
        Approvers not named are removed and new ones added, as
        updateInvoiceApprovers does and with its rules; those who stay move to
        the step they are named in. A step someone approved is locked: it keeps
        its approvers and its place; an approval recorded with one step stays in
        the first step. Approvers whose turn begins are asked. Recorded in the
        invoice's activity.
      operationId: setInvoiceApprovalSteps
      parameters:
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
          description: >-
            The organization to act in. Required for personal API keys; list the
            organizations you can access with GET /v1/organizations.
        - schema:
            type: string
            format: uuid
          required: true
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetInvoiceApprovalSteps'
      responses:
        '200':
          description: The invoice with its new steps.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '400':
          description: >-
            A step without approvers, an approver in two steps, an added user is
            not a member with write access who can see the invoice, or the
            change would leave the caller unable to see the invoice. Nothing
            changed.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: validation_error
                  message: >-
                    A step without approvers, an approver in two steps, an added
                    user is not a member with write access who can see the
                    invoice, or the change would leave the caller unable to see
                    the invoice. Nothing changed.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_validation_error'
        '401':
          description: The bearer token is missing or invalid.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
            WWW-Authenticate:
              schema:
                type: string
              required: false
              description: Bearer authentication challenge, when supplied.
          content:
            application/json:
              example:
                error:
                  code: invalid_token
                  message: The bearer token is missing or invalid.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_invalid_token'
        '403':
          description: >-
            Access denied. The error code says why: forbidden, token_disabled,
            organization_required, insufficient_role or mfa_required.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: forbidden
                  message: >-
                    Access denied. The error code says why: forbidden,
                    token_disabled, organization_required, insufficient_role or
                    mfa_required.
                  request_id: req_example
              schema:
                $ref: >-
                  #/components/schemas/Error_forbidden_token_disabled_organization_required_insufficient_role_mfa_required
        '404':
          description: The resource does not exist in the current organization.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: not_found
                  message: The resource does not exist in the current organization.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_not_found'
        '409':
          description: >-
            The invoice is approved, closed or deleted, the change would alter a
            step someone approved or move a recorded approval out of the first
            step, or other work was changing the invoice (retry). Nothing
            changed.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: conflict
                  message: >-
                    The invoice is approved, closed or deleted, the change would
                    alter a step someone approved or move a recorded approval
                    out of the first step, or other work was changing the
                    invoice (retry). Nothing changed.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_conflict'
        '429':
          description: Too many requests. Wait for the Retry-After delay before retrying.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
            Retry-After:
              schema:
                type: string
                example: '60'
              required: true
              description: Seconds to wait before retrying the request.
          content:
            application/json:
              example:
                error:
                  code: rate_limit_exceeded
                  message: >-
                    Too many requests. Wait for the Retry-After delay before
                    retrying.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_rate_limit_exceeded'
        '500':
          description: >-
            Unexpected server failure. Include the request ID when contacting
            support.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: internal_error
                  message: >-
                    Unexpected server failure. Include the request ID when
                    contacting support.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_internal_error'
        '503':
          description: >-
            Temporarily unavailable. Retry after the Retry-After delay, when
            provided.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
            Retry-After:
              schema:
                type: string
                example: '60'
              required: true
              description: Seconds to wait before retrying the request.
          content:
            application/json:
              example:
                error:
                  code: service_unavailable
                  message: >-
                    Temporarily unavailable. Retry after the Retry-After delay,
                    when provided.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_service_unavailable'
      security:
        - ApiKeyBearer: []
components:
  schemas:
    SetInvoiceApprovalSteps:
      type: object
      properties:
        steps:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceApprovalStep'
          minItems: 1
          maxItems: 10
          description: >-
            Every approver of the invoice, in steps, first step first. Each step
            needs at least one approver, and an approver is in one step only.
      required:
        - steps
      additionalProperties: false
    Invoice:
      type: object
      properties:
        company_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            The invoice's company, its recipient's. Null while no rule placed
            it: nothing works on it until someone chooses one
            (setInvoiceCompany).
        suggested_company_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            For an invoice without a company: the company its printed buyer
            likely names, for a person to accept with setInvoiceCompany. Never
            applied by itself; null otherwise.
        id:
          type: string
          format: uuid
        url:
          type: string
          format: uri
          description: The invoice in the Watchdog app.
        invoice_number:
          type:
            - string
            - 'null'
        title:
          type:
            - string
            - 'null'
        category:
          type: string
          enum:
            - invoice
            - credit_note
            - self_billed_invoice
            - reminder
            - collection_notice
        issued_date:
          type:
            - string
            - 'null'
          format: date
        due_date:
          type:
            - string
            - 'null'
          format: date
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
        supplier:
          $ref: '#/components/schemas/InvoicePartyDetail'
        recipient:
          $ref: '#/components/schemas/InvoiceRecipientDetail'
        amounts:
          $ref: '#/components/schemas/InvoiceAmountsDetail'
        review:
          $ref: '#/components/schemas/InvoiceReview'
        stage:
          type:
            - string
            - 'null'
          enum:
            - inbox
            - needs_approval
            - on_hold
            - approved
            - rejected
            - null
          description: >-
            Superseded by lifecycle, the invoice's one status; removed once the
            app no longer reads it. Watchdog's approval flow, from Watchdog's
            facts only: rejected (closed) or approved as decided, on_hold,
            needs_approval while it has approvers, else inbox. Null outside the
            flow (see the invoice's outside_flow).
        outside_flow:
          type:
            - string
            - 'null'
          enum:
            - cancelled_in_source
            - accounting_history
            - null
          description: >-
            Superseded by lifecycle; removed once the app no longer reads it.
            Why stage is null: cancelled_in_source (its accounting system
            cancelled it), or accounting_history (marked as history on arrival;
            new arrivals qualify through posted rows or a settled source
            balance, not source approval).
        lifecycle:
          $ref: '#/components/schemas/InvoiceLifecycle'
        accounting:
          $ref: '#/components/schemas/InvoiceAccountingState'
        overdue:
          type: boolean
          description: >-
            True when it still waits on Watchdog past its due date (Oslo date):
            its lifecycle.status is in Inbox or Approval, or it is approved and
            not yet sent (not_ready_to_send, ready_to_send, send_failed). Once
            it is in the accounting system or done, it is not overdue.
        approvers:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceDetailApprover'
          description: >-
            The people asked to approve the invoice, in the order they were
            added.
        approver_teams:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceDetailApproverTeam'
          description: >-
            The teams asked to approve the invoice, in the order they were
            added. Each counts as one approver toward required_approvals.
        required_approvals:
          type: integer
          minimum: 1
          description: >-
            How many approvers must approve the invoice: the organization's
            approval policy setting, however many approval steps it has. With
            fewer approvers than this, add more before it can be approved.
        assigning_approvers:
          type: boolean
          description: >-
            Approvers come once it is read, matched to its orders and coded: its
            orders' invoice approvers, else rules.
        policy_approval:
          type:
            - string
            - 'null'
          enum:
            - waiting
            - decided
            - null
          description: >-
            The approval policy decides instead of people: waiting (not
            evaluated yet, no approvers) or decided. Null when people decide.
        background_runs:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceBackgroundRun'
          description: >-
            The latest run of each background area the invoice has had. Poll
            check_progress until it is no longer running, then read alerts and
            checks.
        alerts:
          $ref: '#/components/schemas/InvoiceAlerts'
        checks:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceCheck'
          description: One entry per check type, limited to the same scope as alerts.
        check_progress:
          type: string
          enum:
            - running
            - failed
            - settled
          description: >-
            Whether the invoice's checks have settled. running: a background run
            (also one waiting for its sync or batch) or a check is in progress;
            failed: a background run or a check failed and waits for its
            automatic retry or a person; settled: neither. Poll it after a
            change, then read alerts and checks. Approving one invoice is
            allowed either way and its activity records this; bulk approval
            skips unsettled invoices.
        relationships:
          type: object
          properties:
            letter_count:
              type: integer
              minimum: 0
              description: >-
                Readable letters linked to this invoice, listed at GET
                /v1/invoices/{id}/reminders.
            agreement_count:
              type: integer
              minimum: 0
              description: Matched agreements, listed at GET /v1/invoices/{id}/agreements.
            alert_count:
              type: integer
              minimum: 0
              description: >-
                Alerts on the invoice, including false alarms and unsure ones,
                listed at GET /v1/alerts?invoice_ids={id}.
            linked_credit_note_count:
              type: integer
              minimum: 0
              description: >-
                Credit notes linked to this invoice, including soft-deleted
                ones.
            matched_invoice_count:
              type: integer
              minimum: 0
              description: >-
                Invoices this credit note is matched to, including soft-deleted
                ones.
            line_item_count:
              type: integer
              minimum: 0
              description: Listed at GET /v1/invoices/{id}/line-items.
            document_count:
              type: integer
              minimum: 0
              description: Listed at GET /v1/invoices/{id}/documents.
          required:
            - letter_count
            - agreement_count
            - alert_count
            - linked_credit_note_count
            - matched_invoice_count
            - line_item_count
            - document_count
        current_step:
          type:
            - integer
            - 'null'
          minimum: 1
          description: >-
            The approval step whose turn it is (WD-2901): the first step nobody
            in it has approved. Approvers of later steps wait their turn. Null
            once every step has an approval, when any approver who has not
            approved may, once the invoice is decided, and while it has no
            approvers.
        letter:
          $ref: '#/components/schemas/InvoiceLetterDetail'
        payment_handoff:
          $ref: '#/components/schemas/InvoicePaymentHandoff'
        amount_owed:
          allOf:
            - $ref: '#/components/schemas/InvoiceAmountOwed'
            - description: >-
                Detail only, on an invoice letters chase: what we owe on it and
                its letters.
        suggested_approvers:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceSuggestedApprover'
          description: >-
            Detail only. Invoice approvers of its purchase orders who are not on
            it and could approve it now, as when an order was linked after it
            got its approvers. Nothing adds them by itself; add them with
            updateInvoiceApprovers. Empty once it is decided and while it waits
            for its approvers.
        note:
          type:
            - string
            - 'null'
          description: >-
            The invoice-wide note in its original wording. Null means
            unavailable; empty text stays empty.
        payment:
          $ref: '#/components/schemas/InvoicePayment'
        delivery:
          type: object
          properties:
            name:
              type:
                - string
                - 'null'
            address:
              type: object
              properties:
                street:
                  type:
                    - string
                    - 'null'
                city:
                  type:
                    - string
                    - 'null'
                state:
                  type:
                    - string
                    - 'null'
                postal_code:
                  type:
                    - string
                    - 'null'
                country_code:
                  type:
                    - string
                    - 'null'
              required:
                - street
                - city
                - state
                - postal_code
                - country_code
            date:
              type:
                - string
                - 'null'
              format: date
          required:
            - name
            - address
            - date
        references:
          type: object
          properties:
            order_references:
              type: array
              items:
                type: string
            buyer_reference:
              type:
                - string
                - 'null'
            seller_reference:
              type:
                - string
                - 'null'
            buyer_contact:
              type:
                - object
                - 'null'
              properties:
                name:
                  type:
                    - string
                    - 'null'
                email:
                  type:
                    - string
                    - 'null'
              required:
                - name
                - email
              description: >-
                The buyer's contact person an e-invoice names, often printed as
                Deres ref.
            contract_reference:
              type:
                - string
                - 'null'
            project_reference:
              type:
                - string
                - 'null'
            accounting_cost:
              type:
                - string
                - 'null'
            credit_note_invoice_reference:
              type:
                - string
                - 'null'
          required:
            - order_references
            - buyer_reference
            - seller_reference
            - buyer_contact
            - contract_reference
            - project_reference
            - accounting_cost
            - credit_note_invoice_reference
        additional_properties:
          type:
            - array
            - 'null'
          items:
            type: object
            properties:
              name:
                type: string
              value:
                type: string
              source_path:
                type:
                  - string
                  - 'null'
              scheme:
                type:
                  - string
                  - 'null'
            required:
              - name
              - value
          description: >-
            Other named details found in the source, with where they were found.
            Null when not available; empty when none were found.
        approval:
          $ref: '#/components/schemas/InvoiceApproval'
        sent_back:
          $ref: '#/components/schemas/InvoiceSentBack'
        progress:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceProgressStep'
          description: >-
            The lifecycle: received, approved, booked, paid, each with its own
            state.
        hold:
          $ref: '#/components/schemas/InvoiceHoldState'
        locked:
          type: boolean
          description: >-
            Sent for approval: a record until it is reopened, and every
            correction (updateInvoice, line items, documents, classification)
            returns 409 until then; actions says what the caller may still do.
            False while it is a draft in Inbox, and for an invoice that never
            went through approval in Watchdog.
        intake:
          $ref: '#/components/schemas/InvoiceIntake'
        actions:
          $ref: '#/components/schemas/InvoiceActions'
        voucher:
          $ref: '#/components/schemas/InvoiceVoucher'
        transfer:
          $ref: '#/components/schemas/InvoiceTransfer'
        origin:
          type: object
          properties:
            type:
              type: string
              enum:
                - structured
                - documents
                - integration
                - unknown
              description: >-
                How the invoice was created: from an accounting system, from
                documents (Peppol, email, upload, API import), or from
                structured data.
            import_id:
              type:
                - string
                - 'null'
              format: uuid
              description: The import that created the invoice, when known.
          required:
            - type
            - import_id
        sources:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceSource'
          description: >-
            Every arrival of this invoice, in the order received: an accounting
            system, a Peppol message, an email attachment, an upload or an API
            import. The first created the invoice; later ones are linked.
        approval_evaluation:
          $ref: '#/components/schemas/InvoiceApprovalEvaluation'
      required:
        - company_id
        - suggested_company_id
        - id
        - url
        - invoice_number
        - title
        - category
        - issued_date
        - due_date
        - created_at
        - updated_at
        - deleted_at
        - supplier
        - recipient
        - amounts
        - review
        - stage
        - outside_flow
        - lifecycle
        - accounting
        - overdue
        - approvers
        - approver_teams
        - required_approvals
        - assigning_approvers
        - policy_approval
        - background_runs
        - alerts
        - checks
        - check_progress
        - relationships
        - current_step
        - letter
        - payment_handoff
        - amount_owed
        - suggested_approvers
        - note
        - payment
        - delivery
        - references
        - additional_properties
        - approval
        - sent_back
        - progress
        - hold
        - locked
        - intake
        - actions
        - voucher
        - transfer
        - origin
        - sources
        - approval_evaluation
    Error_validation_error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - validation_error
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_invalid_token:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - invalid_token
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_forbidden_token_disabled_organization_required_insufficient_role_mfa_required:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - forbidden
                - token_disabled
                - organization_required
                - insufficient_role
                - mfa_required
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_not_found:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - not_found
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_conflict:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - conflict
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_rate_limit_exceeded:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - rate_limit_exceeded
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_internal_error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - internal_error
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_service_unavailable:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - service_unavailable
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    InvoiceApprovalStep:
      type: object
      properties:
        user_ids:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 255
          maxItems: 20
          default: []
          description: Members who approve in this step.
        team_ids:
          type: array
          items:
            type: string
            format: uuid
          maxItems: 20
          default: []
          description: >-
            Teams that approve in this step; any one member decides for the
            team.
      additionalProperties: false
    InvoicePartyDetail:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
          format: uuid
          description: The supplier in Watchdog. Null until a person chooses it in Inbox.
        name:
          type:
            - string
            - 'null'
          description: The party's current name in Watchdog.
        invoiced_as:
          type: object
          properties:
            name:
              type:
                - string
                - 'null'
            organization_number:
              type:
                - string
                - 'null'
            main_name:
              type:
                - string
                - 'null'
            department:
              type:
                - string
                - 'null'
            email:
              type:
                - string
                - 'null'
            website:
              type:
                - string
                - 'null'
            address:
              type: object
              properties:
                street:
                  type:
                    - string
                    - 'null'
                city:
                  type:
                    - string
                    - 'null'
                state:
                  type:
                    - string
                    - 'null'
                postal_code:
                  type:
                    - string
                    - 'null'
                country_code:
                  type:
                    - string
                    - 'null'
              required:
                - street
                - city
                - state
                - postal_code
                - country_code
          required:
            - name
            - organization_number
            - main_name
            - department
            - email
            - website
            - address
          description: >-
            The party as printed on the invoice. Reassigning the party changes
            id, never this.
      required:
        - id
        - name
        - invoiced_as
    InvoiceRecipientDetail:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Null until the recipient is resolved, or when a letter does not
            identify its debtor.
        name:
          type:
            - string
            - 'null'
        invoiced_as:
          type: object
          properties:
            name:
              type:
                - string
                - 'null'
            organization_number:
              type:
                - string
                - 'null'
            main_name:
              type:
                - string
                - 'null'
            department:
              type:
                - string
                - 'null'
            email:
              type:
                - string
                - 'null'
            website:
              type:
                - string
                - 'null'
            address:
              type: object
              properties:
                street:
                  type:
                    - string
                    - 'null'
                city:
                  type:
                    - string
                    - 'null'
                state:
                  type:
                    - string
                    - 'null'
                postal_code:
                  type:
                    - string
                    - 'null'
                country_code:
                  type:
                    - string
                    - 'null'
              required:
                - street
                - city
                - state
                - postal_code
                - country_code
          required:
            - name
            - organization_number
            - main_name
            - department
            - email
            - website
            - address
          description: >-
            The party as printed on the invoice. Reassigning the party changes
            id, never this.
      required:
        - id
        - name
        - invoiced_as
    InvoiceAmountsDetail:
      type: object
      properties:
        currency_code:
          type:
            - string
            - 'null'
          description: Currency of every amount on the invoice.
        excluding_vat:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: Invoice total excluding VAT. Null when unknown.
          example: '1250.00'
        including_vat:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: Invoice total including VAT. Null when unknown.
          example: '1250.00'
        prepaid:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: >-
            Exact decimal as a string. Parse it as a decimal, not a
            floating-point number.
          example: '1250.00'
        rounding:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: >-
            Exact decimal as a string. Parse it as a decimal, not a
            floating-point number.
          example: '1250.00'
        payable:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: >-
            Amount to pay: including_vat − prepaid + rounding. Null when not
            read.
          example: '1250.00'
        original:
          type:
            - object
            - 'null'
          properties:
            currency_code:
              type: string
            including_vat:
              type:
                - string
                - 'null'
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: >-
                Exact decimal as a string. Parse it as a decimal, not a
                floating-point number.
              example: '1250.00'
            conversion_rate:
              type:
                - string
                - 'null'
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: >-
                Units of currency_code per original unit. Null when no rate was
                recorded.
              example: '1250.00'
          required:
            - currency_code
            - including_vat
            - conversion_rate
          description: >-
            The printed currency and total before conversion; null when none was
            recorded.
        valid:
          type: boolean
          readOnly: true
          description: >-
            Whether the amounts add up, within 1 currency unit. Says nothing
            about extraction accuracy or compliance.
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                enum:
                  - missing_financial_inputs
                  - line_calculation_mismatch
                  - invoice_total_mismatch
                  - invoice_subtotal_mismatch
                  - category_amount_mismatch
                  - payable_amount_mismatch
              field:
                type: string
              message:
                type: string
            required:
              - code
              - field
              - message
          readOnly: true
          description: Why valid is false; field is the path of the failing field.
        transfer_mismatches:
          type: array
          items:
            type: string
          readOnly: true
          description: >-
            The amounts that keep transferInvoice from sending
            (amounts_mismatch), by path: amounts.payable or
            amounts.including_vat. Sending needs them to agree exactly, not
            within 1 unit: payable is including_vat − prepaid + rounding, and
            including_vat is the lines with VAT within 0.005 per line plus
            0.005, or, when the lines add up exactly to excluding_vat, VAT
            within 0.10 of theirs (or the per-line allowance when more). Empty
            for an invoice Watchdog never sends: one an accounting system
            delivered, or one outside the flow.
      required:
        - currency_code
        - excluding_vat
        - including_vat
        - prepaid
        - rounding
        - payable
        - original
        - valid
        - errors
        - transfer_mismatches
    InvoiceReview:
      type: object
      properties:
        recommended:
          type: boolean
          description: >-
            True for unconfirmed low or medium extraction confidence, or amounts
            that do not add up.
        extraction_confidence:
          type: string
          enum:
            - high
            - mid
            - low
            - unknown
          description: >-
            Confidence in the data extracted from a PDF invoice. unknown for
            XML, API-created and manually created invoices.
        confirmed:
          type:
            - object
            - 'null'
          properties:
            at:
              type: string
              format: date-time
            by_user_id:
              type:
                - string
                - 'null'
          required:
            - at
            - by_user_id
          description: True once a person has confirmed the extracted data.
      required:
        - recommended
        - extraction_confidence
        - confirmed
      readOnly: true
    InvoiceLifecycle:
      type: object
      properties:
        status:
          type:
            - string
            - 'null'
          enum:
            - reading
            - missing_info
            - ready_for_approval
            - no_new_charges
            - sent_back
            - awaiting_approval
            - on_hold
            - not_ready_to_send
            - ready_to_send
            - send_failed
            - rejected_in_accounting
            - sent
            - awaiting_payment
            - paid
            - booked
            - closed
            - cancelled
            - null
          description: >-
            Where the invoice is in its life, as one status. Inbox, a draft:
            reading (Watchdog is still working on it), missing_info (something
            must be fixed before it is sent for approval; see blockers),
            ready_for_approval (ready to send for approval with
            send_for_approval: one a person worked on, one with review_issues,
            or without approvers), sent_back (an approver sent it back to be
            fixed; see sent_back), no_new_charges (a letter that adds no charge
            of its own: what it asks is paid through the invoices and letters it
            chases, so it is never approved; a person completes it with close).
            Approval, once sent: awaiting_approval, on_hold. Payment:
            not_ready_to_send (sending would be refused now; see blockers),
            ready_to_send, send_failed, rejected_in_accounting (rejected in the
            accounting system's own approval after it was sent), sent (in the
            accounting system, not booked yet), awaiting_payment (booked there,
            not paid). Done: paid (the accounting system states nothing
            outstanding, or payment.paid_mark), booked (a credit note booked
            there), closed (in Watchdog, without payment; a reopen undoes it),
            cancelled (in its source). Watchdog sends a clean arrival with
            approvers and no review_issues itself. Once sent, an invoice stays
            in Approval whatever happens to it until it is reopened or sent
            back, and approving it is never blocked; it follows its accounting
            system wherever it came from. Null for a deleted invoice.
        phase:
          type:
            - string
            - 'null'
          enum:
            - inbox
            - approval
            - payment
            - done
            - null
          description: >-
            The phase of status: inbox, approval, payment or done. Null with
            status.
        blockers:
          type: array
          items:
            type: string
            enum:
              - no_company
              - no_supplier
              - uncoded_lines
              - supplier_not_in_erp
              - not_coded
              - no_connection
              - connection_disabled
              - sign_in_missing
              - sign_in_expired
              - currency_unsupported
          description: >-
            Why the invoice waits: for missing_info, and while reading or
            sent_back, what holds it in Inbox: no_company, uncoded_lines (its
            coding is not complete and valid), supplier_not_in_erp (its supplier
            is not in the accounting system its company sends to: create it
            there with createErpSupplier or link it with linkErpSupplier, since
            Watchdog never adds it on its own). Sending it for approval is
            refused while any of these applies. For not_ready_to_send, the
            reason sending to the accounting system would be refused
            (send_to.blocked), such as not_coded when the accounting system no
            longer accepts its coding, or supplier_not_in_erp. Empty otherwise.
        review_issues:
          type: array
          items:
            type: string
            enum:
              - needs_review
              - letter_missing_original
              - letter_reading_attention
          description: >-
            While it is decided, in Inbox and Approval, what a person should
            check, never holding it: needs_review (its reading or amounts are
            unsure; see review and amounts.errors), letter_missing_original (a
            claim with no linked invoice), letter_reading_attention (see
            letter.issues). Fixing the data clears it.
        closed_on:
          type:
            - string
            - 'null'
          format: date
          description: >-
            When it reached Done (Oslo date): paid on, a credit note paid or
            booked on, closed on. Null before Done and for a cancellation.
        next_action:
          type:
            - object
            - 'null'
          properties:
            kind:
              type: string
              enum:
                - review
                - choose_approvers
                - send_for_approval
                - complete
                - approve
                - assess
                - release_hold
                - send
                - retry
                - resolve_rejection
              description: >-
                review (fix what is missing or stops the send),
                choose_approvers, send_for_approval (updateInvoice with
                send_for_approval), complete (a letter with no new charges:
                checked, then closed with updateInvoice close), approve, assess
                (approve, with open avvik to look at first), release_hold, send
                (to the accounting system), retry, resolve_rejection (send again
                or reject in Watchdog).
            mine:
              type: boolean
              description: The caller is one who takes this action.
            waiting_on:
              type: array
              items:
                type: string
              description: >-
                User IDs the action waits on when it is not the caller's: the
                approvers yet to approve, or who put it on hold. Empty when it
                falls to the workspace's admins.
          required:
            - kind
            - mine
            - waiting_on
          description: >-
            What moves the invoice on from its status, and whose move it is.
            Null when nobody in Watchdog has anything to do.
      required:
        - status
        - phase
        - blockers
        - review_issues
        - closed_on
        - next_action
      description: >-
        The invoice's lifecycle, the one status every screen shows. Filter with
        phase, lifecycle_statuses and actionable; count with GET
        /v1/invoices/lifecycle-counts.
    InvoiceAccountingState:
      type: object
      properties:
        system_name:
          type:
            - string
            - 'null'
          description: >-
            The accounting system holding a copy, such as Tripletex; null when
            none.
        link:
          $ref: '#/components/schemas/InvoiceAccountingLink'
        approval:
          type:
            - string
            - 'null'
          enum:
            - approved
            - rejected
            - pending
            - null
          description: >-
            That system's own approval; null when it states none. Tripletex
            states it only for an invoice Watchdog sent, read nightly until it
            is booked.
        rejection:
          $ref: '#/components/schemas/InvoiceAccountingRejection'
        booking:
          type:
            - object
            - 'null'
          properties:
            system_name:
              type:
                - string
                - 'null'
              description: >-
                The accounting system that booked it; null for an ERP imported
                without a connection.
          required:
            - system_name
          description: >-
            Set once an accounting system booked it (Eye-Share: transferred),
            naming that system, which can differ from system_name. Rows are
            under voucher.
        not_booked:
          type: boolean
          description: >-
            Watchdog sent it to be booked, and the accounting system did not
            book it.
        status:
          $ref: '#/components/schemas/InvoiceAccountingStatus'
      required:
        - system_name
        - link
        - approval
        - rejection
        - booking
        - not_booked
        - status
      description: >-
        The accounting system's own state of the invoice, apart from Watchdog's
        approval. Payment is under payment.
    InvoiceDetailApprover:
      allOf:
        - $ref: '#/components/schemas/InvoiceApprover'
        - type: object
          properties:
            step:
              type: integer
              minimum: 1
              description: >-
                The approval step the approver is in, 1 first (WD-2901). Steps
                set only the order: one approval completes a step and the next
                step's turn begins; the invoice is approved once
                required_approvals approvers have approved, in whichever step.
                Edit with setInvoiceApprovalSteps.
          required:
            - step
    InvoiceDetailApproverTeam:
      allOf:
        - $ref: '#/components/schemas/InvoiceApproverTeam'
        - type: object
          properties:
            nobody_can_act:
              type: boolean
              description: >-
                Nobody in the team can approve the invoice now: no member has
                write access and can see it. Add someone to the team, or add
                another approver. False once the team has approved or the
                invoice is decided, and in exports.
            step:
              type: integer
              minimum: 1
              description: >-
                The approval step the approver is in, 1 first (WD-2901). Steps
                set only the order: one approval completes a step and the next
                step's turn begins; the invoice is approved once
                required_approvals approvers have approved, in whichever step.
                Edit with setInvoiceApprovalSteps.
          required:
            - nobody_can_act
            - step
    InvoiceBackgroundRun:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The run. Retry an unsuccessful one with retryWorkflowRun.
        area:
          type: string
          enum:
            - agreements
            - credit_notes
            - purchase_orders
          description: >-
            agreements: smart matching, then the invoice's first agreement
            checks. credit_notes: matching a credit note to the invoices it
            credits, allocating its lines, then recording what settles a claim.
            purchase_orders: matching the invoice to an order, then its lines to
            the order's lines.
        status:
          type: string
          enum:
            - queued
            - running
            - completed
            - completed_with_errors
            - failed
            - cancelled
        failed_steps:
          type: array
          items:
            type: object
            properties:
              step:
                type: string
                enum:
                  - smart_match
                  - initial_checks
                  - match
                  - recover
                  - allocate
                  - match_order
                  - allocate_lines
              failure:
                type: object
                properties:
                  code:
                    type: string
                    minLength: 1
                    maxLength: 100
                  message:
                    type: string
                    minLength: 1
                    maxLength: 2000
                required:
                  - code
                  - message
            required:
              - step
              - failure
          description: The steps that failed, and why.
        waiting_for_import:
          type: boolean
          description: >-
            True while the run waits for the sync or import batch that delivered
            the invoice to finish, or for a purchase-order sync whose orders it
            may bill and every order matching run that sync started.
        retry_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When the unsuccessful run retries itself; null when it does not, as
            when its retries are spent and it needs a person to retry it.
        finished_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - area
        - status
        - failed_steps
        - waiting_for_import
        - retry_at
        - finished_at
      description: >-
        The latest run of one of the invoice's background areas: the model work
        a change of the invoice owes. A change requests the areas it affects; a
        request joins the area's open run.
    InvoiceAlerts:
      type: object
      properties:
        status:
          type: string
          enum:
            - credited
            - checking
            - has_issues
            - clean
            - not_checked
          description: >-
            Overall alert status over the checks in scope (see check_status):
            credited (covered by credit notes), checking (a check is running;
            results may change), has_issues (open alerts), clean (a check
            completed, no open alerts), or not_checked.
        check_status:
          type: string
          enum:
            - not_checkable
            - checking
            - not_checked
            - completed
            - incomplete
          description: >-
            How complete the checks in scope are: completed (every check
            completed), incomplete (some unchecked, failed or cancelled),
            checking, not_checked, or not_checkable (credit notes, letters,
            invoices fully reversed by a credit note, invoices without a
            document). The invoice scope covers every check that applies to the
            invoice: its matched agreements, the purchase orders it bills, and
            its duplicate check. The selected_agreements scope covers the checks
            against those agreements.
        open_alert_count:
          type: integer
          minimum: 0
          description: >-
            Open alerts in scope: live, and neither a false alarm, unsure nor
            credited.
        counts:
          type: object
          properties:
            pending:
              type: object
              properties:
                credited:
                  type: integer
                  minimum: 0
                uncredited:
                  type: integer
                  minimum: 0
              required:
                - credited
                - uncredited
            accepted:
              type: object
              properties:
                credited:
                  type: integer
                  minimum: 0
                uncredited:
                  type: integer
                  minimum: 0
              required:
                - credited
                - uncredited
            dismissed:
              type: object
              properties:
                credited:
                  type: integer
                  minimum: 0
                uncredited:
                  type: integer
                  minimum: 0
              required:
                - credited
                - uncredited
            skipped:
              type: object
              properties:
                credited:
                  type: integer
                  minimum: 0
                uncredited:
                  type: integer
                  minimum: 0
              required:
                - credited
                - uncredited
          required:
            - pending
            - accepted
            - dismissed
            - skipped
          description: >-
            Alerts by verdict and credit, including false alarms and unsure
            ones.
        replaceable_alert_count:
          type: integer
          minimum: 0
          description: >-
            Alerts in counts that checking the invoice again can replace,
            whatever their verdict: all but those on an agreement a claim holds
            for this invoice (a claim that is not cancelled with one of the
            pair's alerts that is not a false alarm). A check that completes
            closes them as replaced and opens its findings as new alerts to
            review.
        agreements:
          type: object
          properties:
            total:
              type: integer
              minimum: 0
              description: Currently matched agreements in scope.
            checked:
              type: integer
              minimum: 0
              description: Matched agreements in scope with a completed check.
          required:
            - total
            - checked
          description: The matched agreements the checks cover.
        scope:
          type: object
          properties:
            type:
              type: string
              enum:
                - invoice
                - selected_agreements
              description: >-
                invoice covers all checks and alerts; selected_agreements covers
                only the selected agreements.
            agreement_ids:
              type:
                - array
                - 'null'
              items:
                type: string
                format: uuid
              maxItems: 50
              description: The selected agreements; null for the invoice scope.
          required:
            - type
            - agreement_ids
          description: The scope of counts and agreements.
        has_hidden_alerts:
          type: boolean
          description: >-
            True when a team-restricted caller cannot see some live alerts on
            the invoice because their agreement is hidden. Always false for
            Admins and unrestricted callers.
      required:
        - status
        - check_status
        - open_alert_count
        - counts
        - replaceable_alert_count
        - agreements
        - scope
        - has_hidden_alerts
    InvoiceCheck:
      type: object
      properties:
        check_type:
          type: string
          enum:
            - agreement
            - purchase_order
            - duplicate
        status:
          type: string
          enum:
            - not_started
            - waiting
            - not_applicable
            - running
            - completed
            - failed
          description: >-
            not_started: the type applies, but some of its checks have no
            current result (never run, or reset); never read it as passed.
            waiting: the check waits for a prerequisite, named in reason.
            not_applicable: the check does not apply to the invoice; reason says
            why. running: a check is in progress. failed: a check failed or was
            cancelled before completing. completed: every check has a completed
            result.
        reason:
          type:
            - string
            - 'null'
          enum:
            - matching
            - credit_note
            - credit_note_matched
            - no_primary_document
            - no_agreements
            - no_purchase_order
            - purchase_order_not_linked
            - purchase_order_reconciling
            - purchase_order_lines_unassigned
            - null
          description: >-
            Why the check waits or does not apply. matching: the invoice's
            agreements or purchase-orders background run is still matching it.
            credit_note, credit_note_matched (a credit note fully reverses the
            invoice), no_primary_document: the invoice cannot be checked.
            no_agreements: matching found no agreement. no_purchase_order: the
            invoice cites no order and none is accepted.
            purchase_order_not_linked: it cites an order and none is accepted
            yet; it is checked once one is accepted and its lines are assigned
            (the invoice's purchase-order suggestions say which).
            purchase_order_reconciling: matching is still settling an accepted
            order's invoices. purchase_order_lines_unassigned: orders are
            accepted but none of the invoice's lines is assigned to one yet.
            Null for other statuses.
        open_alert_count:
          type: integer
          minimum: 0
          description: >-
            Open alerts of this check type in scope: live, and neither a false
            alarm, unsure nor credited.
        review_alert_count:
          type: integer
          minimum: 0
          description: >-
            Of the open alerts, those still to review: nobody has confirmed them
            yet. The rest of open_alert_count are confirmed.
        complete:
          type:
            - boolean
            - 'null'
          description: >-
            Whether the completed checks covered everything they set out to
            check. False when one was cut short by its budget or left entries of
            its answer out as invalid. Null when no check of this type is
            completed.
      required:
        - check_type
        - status
        - reason
        - open_alert_count
        - review_alert_count
        - complete
    InvoiceLetterDetail:
      type:
        - object
        - 'null'
      properties:
        printed_stage:
          type:
            - string
            - 'null'
        amount_demanded:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
        charges_known:
          type: boolean
        sender:
          $ref: '#/components/schemas/InvoiceLetterParty'
        payee:
          $ref: '#/components/schemas/InvoiceLetterParty'
        payments:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceLetterPayment'
          description: What the letter prints as already paid.
        issues:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceLetterIssue'
          description: >-
            What about the letter a person must check: charges_unknown (its
            charges were not read), currency_unknown, sender_unknown (read as a
            reminder from its creditor), demand_mismatch (what it chases and
            adds does not make up what it asks for), may_repeat_charge (an
            invoice it chases is not linked, so an earlier letter may have
            charged the same), sources_disagree (its XML and PDF state different
            payment details: see source_discrepancies).
        source_discrepancies:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceLetterSourceDiscrepancy'
          description: >-
            Where its XML and PDF state different values. The letter keeps the
            PDF amount and the XML payment reference and account until a person
            writes that field, which settles it.
        claims:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceLetterClaim'
        charges:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceLetterPrintedCharge'
          description: The charges as the letter prints them.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceLetterLine'
          description: >-
            Per kind of charge it prints, what it books after what earlier
            letters booked.
        amount_owed:
          $ref: '#/components/schemas/InvoiceAmountOwed'
        flags:
          $ref: '#/components/schemas/InvoiceLetterFlags'
        can_link_claims:
          type: boolean
      required:
        - printed_stage
        - amount_demanded
        - charges_known
        - sender
        - payee
        - payments
        - issues
        - source_discrepancies
        - claims
        - charges
        - lines
        - amount_owed
        - flags
        - can_link_claims
    InvoicePaymentHandoff:
      type:
        - object
        - 'null'
      properties:
        state:
          type: string
          enum:
            - ready
            - manual
          description: >-
            ready: sending the invoice gives the payment it registers the
            letter's KID and due date; sending pays nothing itself. manual: a
            person pays it as the letter says.
        reason:
          type:
            - string
            - 'null'
          enum:
            - collector
            - several_invoices
            - invalid_reference
            - partly_paid
            - new_account
            - changed_after_transfer
            - null
          description: 'Why a person pays it: what the letter changes that sending cannot.'
        letter:
          type: object
          properties:
            id:
              type: string
              format: uuid
            category:
              type: string
              enum:
                - reminder
                - collection_notice
            issued_date:
              type:
                - string
                - 'null'
              format: date
          required:
            - id
            - category
            - issued_date
        payee:
          type:
            - string
            - 'null'
        account:
          type:
            - string
            - 'null'
        reference:
          type:
            - string
            - 'null'
        reference_kind:
          type:
            - string
            - 'null'
        due_date:
          type:
            - string
            - 'null'
          format: date
      required:
        - state
        - reason
        - letter
        - payee
        - account
        - reference
        - reference_kind
        - due_date
      description: >-
        How the newest letter chasing the invoice says to pay it. Null when no
        letter chases it, and once it is paid: what remains is the letters' own
        charges, decided on each letter.
    InvoiceAmountOwed:
      type:
        - object
        - 'null'
      properties:
        currency:
          type:
            - string
            - 'null'
        lines:
          type: array
          items:
            type: object
            properties:
              invoice_id:
                type: string
                format: uuid
              invoice_number:
                type:
                  - string
                  - 'null'
              issued_date:
                type:
                  - string
                  - 'null'
                format: date
              kind:
                type: string
                enum:
                  - invoice
                  - credit_note
                  - charges
                description: >-
                  An invoice or credit note owes what is outstanding on it; a
                  letter's charges what it adds.
              letter_category:
                type:
                  - string
                  - 'null'
                enum:
                  - reminder
                  - collection_notice
                  - null
                description: >-
                  Which letter a charges line is; null on an invoice or credit
                  note.
              amount:
                type:
                  - string
                  - 'null'
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Null while the accounting system has not said what is
                  outstanding.
              source:
                type: string
                enum:
                  - accounting_system
                  - watchdog
              read_at:
                type:
                  - string
                  - 'null'
                format: date-time
            required:
              - invoice_id
              - invoice_number
              - issued_date
              - kind
              - letter_category
              - amount
              - source
              - read_at
        total:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: Null while any line is unknown.
        charges:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: >-
            What the letters add in fees and interest, paid or not; a rejected
            letter adds nothing. Null while a letter is hidden from the caller
            or currencies differ.
        claimed:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: A letter's printed demand, for comparison.
        difference:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: What the letter claims beyond the total.
      required:
        - currency
        - lines
        - total
        - charges
        - claimed
        - difference
    InvoiceSuggestedApprover:
      type: object
      properties:
        user_id:
          type:
            - string
            - 'null'
        team_id:
          type:
            - string
            - 'null'
          format: uuid
        name:
          type:
            - string
            - 'null'
        purchase_order:
          type: object
          properties:
            id:
              type: string
              format: uuid
            number:
              type:
                - string
                - 'null'
          required:
            - id
            - number
      required:
        - user_id
        - team_id
        - name
        - purchase_order
    InvoicePayment:
      type: object
      properties:
        status:
          type: string
          enum:
            - paid
            - unpaid
            - unknown
          description: >-
            paid when outstanding.amount is zero, or while paid_mark is set;
            unpaid when it is not zero, unknown when it is null.
        paid_mark:
          type:
            - object
            - 'null'
          properties:
            paid_on:
              type: string
              format: date
            at:
              type: string
              format: date-time
            by:
              $ref: '#/components/schemas/InvoicePerson'
          required:
            - paid_on
            - at
            - by
          description: >-
            A person said it is paid on paid_on (by, at) while its accounting
            system cannot read it (outstanding.unreadable_since). It counts
            until that system reads it again and its answer replaces this. Set
            or remove with updateInvoice's paid_mark.
        can_mark_paid:
          type: boolean
          description: >-
            Whether the caller may set paid_mark now: the system cannot read it,
            and the caller is an admin, in the AP team or an approver.
        terms:
          type:
            - string
            - 'null'
          description: >-
            Payment terms as printed, including conditions. Never inferred from
            due_date.
        reference:
          type:
            - string
            - 'null'
        reference_kind:
          type:
            - string
            - 'null'
          enum:
            - kid
            - rf
            - se_ocr
            - fi_reference
            - dk_fik
            - message
            - null
          description: >-
            With reference null, the invoice prints one of this kind that fails
            its check.
        bank_account_number:
          type:
            - string
            - 'null'
        outstanding:
          type: object
          properties:
            current:
              type: boolean
              description: >-
                Whether the accounting connection can currently read the figure;
                false when no accounting system holds it, the connection is
                turned off, credentials are rejected, invoice reading is off, or
                the system no longer shows the invoice (unreadable_since). When
                false, the retained amount and read_at may be stale.
            amount:
              type:
                - string
                - 'null'
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: >-
                The amount still owed, as the accounting system states it; null
                when no accounting system holds the invoice or it states no
                balance.
              example: '1250.00'
            read_at:
              type:
                - string
                - 'null'
              format: date-time
              description: >-
                When the accounting system's figure was last read, retained
                while its connection cannot read it; null when it has never been
                read.
            unreadable_since:
              type:
                - string
                - 'null'
              format: date-time
              description: >-
                Since when the accounting system holds the invoice but no longer
                shows it to the connection; amount and read_at are from before.
          required:
            - current
            - amount
            - read_at
            - unreadable_since
      required:
        - status
        - paid_mark
        - can_mark_paid
        - terms
        - reference
        - reference_kind
        - bank_account_number
        - outstanding
    InvoiceApproval:
      type:
        - object
        - 'null'
      properties:
        decision:
          type: string
          enum:
            - approved
            - closed
          description: >-
            approved by its approvers or the approval policy, or closed in
            Watchdog without payment (lifecycle.status closed).
        decided_at:
          type: string
          format: date-time
        decided_by:
          $ref: '#/components/schemas/InvoicePerson'
        decided_by_kind:
          type: string
          enum:
            - person
            - policy
          description: person, or policy (the approval policy; decided_by is null).
        reason:
          type:
            - string
            - 'null'
          description: >-
            Why it was closed; null when approved, and on an invoice closed
            without a reason before reasons were required.
      required:
        - decision
        - decided_at
        - decided_by
        - decided_by_kind
        - reason
      description: >-
        The decision; null until it is approved or closed, and again once
        reopened.
    InvoiceSentBack:
      type:
        - object
        - 'null'
      properties:
        at:
          type: string
          format: date-time
        by:
          $ref: '#/components/schemas/InvoicePerson'
        reason:
          type: string
          description: What the approver asked the AP team to fix.
      required:
        - at
        - by
        - reason
      description: >-
        Set while the invoice is sent back to Inbox (lifecycle.status
        sent_back): who sent it back, when and why. Null once it is sent for
        approval again.
    InvoiceProgressStep:
      type: object
      properties:
        step:
          type: string
          enum:
            - received
            - checks
            - coding
            - approved
            - booked
            - paid
        status:
          type: string
          enum:
            - done
            - current
            - pending
            - blocked
            - skipped
          description: >-
            done; current: the one step it is working toward (approval, then
            booking, then payment); pending: not reached, or a check or coding
            still under way; blocked: closed, rejected in the accounting system,
            failed or cancelled; skipped: passed by without Watchdog.
        state:
          type: string
          enum:
            - received
            - needs_company
            - checking
            - check_failed
            - issues
            - clean
            - not_checked
            - suggesting
            - needs_coding
            - coded
            - no_coding
            - needs_approver
            - assigning_approvers
            - auto_check
            - waiting
            - on_hold
            - approved
            - closed
            - rejected
            - skipped
            - external
            - not_sent
            - sent
            - in_system
            - failed
            - booked
            - cancelled
            - not_paid
            - paid
            - unknown
          description: >-
            received, checks, coding, approved: Watchdog. booked, paid: the
            accounting system. needs_company: waiting for its company
            (setInvoiceCompany). checking: a check is running; check_failed: one
            waits for its retry; issues or clean once checks settle;
            not_checked: nothing to check. suggesting: coding suggestions are
            being made; needs_coding: lines still need coding (detail: how
            many); coded: every line is coded or the accounting system booked
            it; no_coding: coding is off. assigning_approvers: see
            assigning_approvers. auto_check: the approval policy decides it
            first. waiting: for actor, or for any of the approvers when null.
            external: booked before Watchdog saw it. sent: Watchdog sent it, not
            booked yet. rejected on booked: Watchdog sent it and the accounting
            system rejected it in its own approval before booking it (detail:
            their comment). in_system: there already without Watchdog sending
            it. paid: its outstanding amount there is 0; unknown: it states no
            balance, and it is booked there, arrived as its history, or its
            connection keeps no bookings.
        actor:
          allOf:
            - $ref: '#/components/schemas/InvoicePerson'
            - description: Who decided, held it, or is awaited.
        at:
          type:
            - string
            - 'null'
          format: date-time
          description: When this state began, when known; a payment date is midnight UTC.
        detail:
          type:
            - string
            - 'null'
          description: >-
            The hold or close reason, the voucher number once booked, or how
            many lines still need coding.
      required:
        - step
        - status
        - state
        - actor
        - at
        - detail
    InvoiceHoldState:
      type:
        - object
        - 'null'
      properties:
        since:
          type: string
          format: date-time
        by:
          $ref: '#/components/schemas/InvoicePerson'
        reason:
          type:
            - string
            - 'null'
          description: What the invoice waits for; null when no reason was given.
      required:
        - since
        - by
        - reason
      description: Set while the invoice is on hold; null otherwise.
    InvoiceIntake:
      type: object
      properties:
        status:
          type: string
          enum:
            - missing_info
            - processing
            - complete
        missing:
          type: array
          items:
            type: string
            enum:
              - company
              - supplier
      required:
        - status
        - missing
      description: >-
        Processing (matching, checks, coding and approvers) starts once the
        invoice has a company and a supplier; a recipient is optional. missing
        says which a person must choose. Complete means that processing ended,
        not that every check passed.
    InvoiceActions:
      type: object
      properties:
        edit:
          $ref: '#/components/schemas/InvoiceAction'
        edit_approvers:
          $ref: '#/components/schemas/InvoiceAction'
        run_checks:
          $ref: '#/components/schemas/InvoiceAction'
        suggest_coding:
          $ref: '#/components/schemas/InvoiceAction'
        code:
          $ref: '#/components/schemas/InvoiceAction'
        send_for_approval:
          $ref: '#/components/schemas/InvoiceAction'
        pull_back:
          $ref: '#/components/schemas/InvoiceAction'
        reopen:
          $ref: '#/components/schemas/InvoiceAction'
        close:
          $ref: '#/components/schemas/InvoiceAction'
        hold:
          $ref: '#/components/schemas/InvoiceAction'
      required:
        - edit
        - edit_approvers
        - run_checks
        - suggest_coding
        - code
        - send_for_approval
        - pull_back
        - reopen
        - close
        - hold
      description: >-
        What the caller may do now, by the rules the writes apply. code:
        updateInvoiceCoding; pull_back: from Approval to Inbox, approvals
        cleared; hold: put on hold or take off. send_for_approval is still
        refused while lifecycle.blockers lists anything.
    InvoiceVoucher:
      type:
        - object
        - 'null'
      properties:
        number:
          type:
            - string
            - 'null'
        postings:
          type: array
          items:
            type: object
            properties:
              kind:
                type: string
                enum:
                  - cost
                  - supplier
                  - customer
                  - system
                description: >-
                  supplier: payables row; customer: customer-account row;
                  system: generated (VAT, rounding).
              account:
                type:
                  - string
                  - 'null'
              vat_code:
                type:
                  - string
                  - 'null'
              dimensions:
                type: array
                items:
                  type: string
              amount:
                type:
                  - string
                  - 'null'
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Net; credits negative. Null when the accounting system does
                  not state it.
                example: '1250.00'
              amount_gross:
                type:
                  - string
                  - 'null'
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Gross; credits negative. Null when the accounting system does
                  not state it.
                example: '1250.00'
            required:
              - kind
              - account
              - vat_code
              - dimensions
              - amount
              - amount_gross
          description: Every row, in row order.
      required:
        - number
        - postings
      description: >-
        The voucher the accounting system booked it on, with names from its
        chart of accounts. Null when none (Tripletex only).
    InvoiceTransfer:
      type:
        - object
        - 'null'
      properties:
        status:
          type: string
          enum:
            - not_sent
            - transferred
            - failed
            - in_accounting_system
          description: >-
            not_sent while it is approved and not sent since its approval or a
            later change to its lines, coding or documents (send it with
            transferInvoice); transferred once the invoice is in the accounting
            system with its documents confirmed, coded and ready to book there;
            failed when the last attempt since the current approval did not get
            it there completely, or stopped after writing the voucher;
            in_accounting_system while it is approved but an accounting system
            delivered it too (its sync or an import settled as a duplicate), or
            sending found the supplier invoice there already and wrote nothing,
            so it is there already and is not sent; its lifecycle.status is then
            sent or later.
        system_name:
          type:
            - string
            - 'null'
          description: >-
            The accounting system, such as Tripletex; null when no connection
            was chosen.
        connection:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
            provider:
              type: string
              description: The provider key, such as tripletex.
          required:
            - id
            - name
            - provider
          description: >-
            The connection it was or will be written through; null when none was
            chosen or it was deleted.
        voucher_id:
          type:
            - string
            - 'null'
          description: >-
            The accounting system's ID for the invoice's voucher; also set when
            an attempt failed after the voucher was written or because it holds
            an earlier version of the invoice, and while not_sent when it was
            sent before the approval or change.
        at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When it was written, or when the last attempt failed; null while
            not_sent.
        supplier_bank_account:
          type:
            - string
            - 'null'
          enum:
            - same
            - card_empty
            - different
            - null
          description: >-
            Once transferred: how the accounting system found the bank account
            sent against its supplier card, which its payments use. different
            when they differ (check with the supplier before paying), card_empty
            when the card has none, same when they agree. Null when no account
            was sent or the system said nothing, and before it is transferred.
        failure:
          type:
            - object
            - 'null'
          properties:
            code:
              $ref: '#/components/schemas/TransferFailureCode'
            message:
              type: string
            retryable:
              type: boolean
              description: >-
                Whether sending again can help once the message is followed;
                false while the invoice is as it is (currency, lines) or
                Watchdog paused sending.
          required:
            - code
            - message
            - retryable
          description: Why the last attempt failed; null once written.
        booking_failure:
          type:
            - object
            - 'null'
          properties:
            code:
              type: string
              enum:
                - approval_required
                - period_locked
                - vat_locked
                - department_locked
                - duplicate
                - permission_missing
                - sign_in_missing
                - sign_in_expired
                - rejected
                - unavailable
                - unconfirmed
                - provider_changed
            message:
              type: string
            retryable:
              type: boolean
              description: >-
                Whether bookInvoice can help once the cause is fixed; false
                while Watchdog paused booking.
          required:
            - code
            - message
            - retryable
          description: >-
            Why the accounting system did not book it after the send. Fix the
            cause, then call bookInvoice or book it there. Null otherwise.
        blocked:
          type:
            - object
            - 'null'
          properties:
            code:
              type: string
              enum:
                - not_coded
                - supplier_not_in_erp
                - no_connection
                - connection_disabled
                - sign_in_missing
                - sign_in_expired
                - currency_unsupported
              description: >-
                not_coded: a line has no account yet. supplier_not_in_erp: the
                supplier is not in the accounting system the company sends to;
                create or link it there (createErpSupplier, linkErpSupplier).
                no_connection: no connection sends invoices any more.
                connection_disabled: the connection is turned off.
                sign_in_missing: no one is signed in on the connection to send
                as. sign_in_expired: that sign-in expired. currency_unsupported:
                the accounting system registers another currency only
                (Tripletex: NOK).
            message:
              type: string
            connection:
              type:
                - object
                - 'null'
              properties:
                id:
                  type: string
                  format: uuid
                name:
                  type: string
                provider:
                  type: string
              required:
                - id
                - name
                - provider
              description: >-
                The connection sending was checked against, where an admin fixes
                it; null for no_connection.
          required:
            - code
            - message
            - connection
          description: >-
            While not_sent or failed: why sending it now would fail, known
            without asking the accounting system; sending it anyway records that
            failure. Null when sending would try, and in the other states.
        deleted_in_accounting_system:
          type:
            - object
            - 'null'
          properties:
            voucher_id:
              type:
                - string
                - 'null'
              description: The voucher the accounting system deleted.
            at:
              type: string
              format: date-time
              description: When Watchdog found it deleted.
          required:
            - voucher_id
            - at
          description: >-
            While not_sent: the accounting system deleted the voucher Watchdog
            sent since its approval. The invoice stays approved; sending it
            again writes a new voucher, or close it if it should not be paid.
            Null otherwise.
      required:
        - status
        - system_name
        - connection
        - voucher_id
        - at
        - supplier_bank_account
        - failure
        - booking_failure
        - blocked
        - deleted_in_accounting_system
      description: >-
        For an invoice or credit note Watchdog received (Peppol, email, upload)
        and approved under accounts payable: whether it was registered in the
        organization's accounting system as a supplier invoice, with its coding
        and payment details (Tripletex: as the person signed in on the
        connection, in Ikke bokførte bilag, its payment waiting for approval
        there or set to pay later), and booked if the integration books what it
        sends. Approving does not send it: transferInvoice does, and sending
        again retries a failed attempt. Only invoices in NOK are written so far;
        others fail as currency_unsupported. A written invoice stays shown after
        the approval is reopened. Credit notes are registered as credit notes.
        Null when there is nothing to send (one not approved under accounts
        payable, or no connection takes invoices), and while an attempt is still
        writing.
    InvoiceSource:
      type: object
      properties:
        id:
          type: string
          format: uuid
        channel:
          type: string
          enum:
            - upload
            - api
            - email
            - integration
            - peppol
          description: >-
            How it arrived: integration (an accounting system), peppol, email,
            upload or api.
        linked:
          type: boolean
          description: >-
            Arrived for an invoice another source had already created. It never
            changes the invoice; the first source decides its data.
        state:
          type: string
          enum:
            - active
            - deleted_in_source
            - cancelled_in_source
            - connection_deleted
          description: >-
            What the source system says about its copy: active,
            deleted_in_source, cancelled_in_source, or connection_deleted.
            Watchdog's own state of the invoice is separate.
        received_at:
          type: string
          format: date-time
        document_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            The file that arrived; for Peppol, the received original. Null for
            an accounting system.
        source_system:
          type:
            - string
            - 'null'
          description: The accounting system, for channel integration.
        source_invoice_id:
          type:
            - string
            - 'null'
          description: The accounting system's ID for its copy.
        outstanding_amount:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: What the accounting system says is left to pay, as a decimal string.
        approval_status:
          type:
            - string
            - 'null'
          enum:
            - pending
            - approved
            - rejected
            - null
          description: The accounting system's own approval of its copy, beside Watchdog's.
        stated:
          type:
            - object
            - 'null'
          properties:
            company_id:
              type:
                - string
                - 'null'
            supplier_id:
              type:
                - string
                - 'null'
              description: The supplier's ID in the accounting system.
            supplier_org_number:
              type:
                - string
                - 'null'
            invoice_number:
              type:
                - string
                - 'null'
            invoice_date:
              type:
                - string
                - 'null'
              pattern: ^\d{4}-\d{2}-\d{2}$
            due_date:
              type:
                - string
                - 'null'
              pattern: ^\d{4}-\d{2}-\d{2}$
            total_incl_vat:
              type:
                - string
                - 'null'
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
            total_excl_vat:
              type:
                - string
                - 'null'
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
            currency:
              type:
                - string
                - 'null'
            payment_reference:
              type:
                - string
                - 'null'
              description: The KID or similar reference to pay with.
          required:
            - company_id
            - supplier_id
            - supplier_org_number
            - invoice_number
            - invoice_date
            - due_date
            - total_incl_vat
            - total_excl_vat
            - currency
            - payment_reference
          description: >-
            What the accounting system states about its copy; the invoice keeps
            what its file says. Totals are in the invoice's currency, a credit
            note negative. A field is null where the system does not state it,
            or before Watchdog has read it there; the object is null for a
            channel other than an accounting system.
        connection:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
          required:
            - id
            - name
          description: >-
            The connection that last read it; null when deleted or not an
            accounting system.
        peppol:
          type:
            - object
            - 'null'
          properties:
            message_id:
              type:
                - string
                - 'null'
            sender:
              type:
                - string
                - 'null'
            receiver:
              type:
                - string
                - 'null'
            document_type:
              type:
                - string
                - 'null'
          required:
            - message_id
            - sender
            - receiver
            - document_type
          description: >-
            How a Peppol message reached Watchdog: AS4 message ID and the SBDH
            parties.
      required:
        - id
        - channel
        - linked
        - state
        - received_at
        - document_id
        - source_system
        - source_invoice_id
        - outstanding_amount
        - approval_status
        - stated
        - connection
        - peppol
    InvoiceApprovalEvaluation:
      type:
        - object
        - 'null'
      properties:
        outcome:
          type: string
          enum:
            - rejected
            - approved
            - none
          description: 'What the policy decided; `none`: a person decides.'
        evaluated_at:
          type: string
          format: date-time
        conditions:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
                description: The condition key.
              passed:
                type: boolean
              sentence:
                type: string
                description: What was found, in English, e.g. "Coding uncertain on line 3".
              reason:
                type:
                  - string
                  - 'null'
                enum:
                  - read_with_confidence
                  - amounts_do_not_add_up
                  - low_confidence
                  - coding_certain
                  - coding_unavailable
                  - already_booked
                  - coding_not_finished
                  - coding_incomplete
                  - coding_uncertain
                  - no_open_alerts
                  - checks_running
                  - checks_failed
                  - open_alerts
                  - amount_under
                  - no_amount_limit
                  - amount_missing
                  - amount_over
                  - amount_other_currency
                  - same_as_always
                  - same_as_always_off
                  - same_as_always_unreadable
                  - same_as_always_too_few
                  - same_as_always_currency
                  - same_as_always_lines
                  - same_as_always_amount
                  - null
                description: Stable code for the sentence; null on older evaluations.
              line:
                type:
                  - integer
                  - 'null'
                description: The invoice line the sentence names, if any.
              amount:
                type:
                  - string
                  - 'null'
                description: The amount limit, for the amount reasons.
              currency:
                type:
                  - string
                  - 'null'
                description: The limit's currency (the organization's).
              count:
                type:
                  - integer
                  - 'null'
                description: Open alerts, or invoices compared for same_as_always reasons.
              tolerance_pct:
                type:
                  - number
                  - 'null'
                description: Amount tolerance in %, for same_as_always reasons.
            required:
              - key
              - passed
              - sentence
              - reason
              - line
              - amount
              - currency
              - count
              - tolerance_pct
          description: Every condition, in display order.
        not_approved_reason:
          type:
            - string
            - 'null'
          enum:
            - read_with_confidence
            - coding_certain
            - no_open_alerts
            - amount_under_limit
            - same_as_always
            - null
          description: The condition that kept auto approve from approving.
      required:
        - outcome
        - evaluated_at
        - conditions
        - not_approved_reason
      description: >-
        The approval policy's evaluation, made once the invoice settled; null
        until then.
    InvoiceAccountingLink:
      type:
        - object
        - 'null'
      properties:
        url:
          type: string
          format: uri
          description: >-
            Opens it in the accounting system's web app, for someone signed in
            there.
        system_name:
          type:
            - string
            - 'null'
          description: That accounting system, such as Tripletex.
      required:
        - url
        - system_name
      description: >-
        Where the invoice opens in an accounting system: its copy there (sent by
        Watchdog or delivered by that system), else the voucher that booked it.
        Null when neither has a web address Watchdog knows for that system or
        connection, and before it is in one.
    InvoiceAccountingRejection:
      type:
        - object
        - 'null'
      properties:
        by:
          type:
            - string
            - 'null'
          description: >-
            Who rejected it, as that system names them; null when it hides the
            name.
        role:
          type:
            - string
            - 'null'
          description: >-
            Their part in that system's approval, such as department manager, as
            it names it; null when it does not.
        comment:
          type:
            - string
            - 'null'
          description: Why, as they wrote it; null when they wrote nothing.
      required:
        - by
        - role
        - comment
      description: >-
        While approval is rejected: who rejected it there and why, each null
        where that system does not say. Null otherwise.
    InvoiceAccountingStatus:
      type:
        - object
        - 'null'
      properties:
        kind:
          type: string
          enum:
            - paid
            - booked
            - rejected
            - pending
            - not_booked
            - sent
            - approved
          description: >-
            The first that holds of: paid there, booked there, rejected in its
            own approval there, and sent by Watchdog and waiting (pending while
            it waits for approval there, not_booked when it did not book it
            although asked to, else sent). An invoice Watchdog did not send
            shows that system's approval (approved, pending).
        system_name:
          type:
            - string
            - 'null'
          description: >-
            The system the status is about: the one that booked it once booked,
            else the one holding its copy; null when unnamed.
        sent_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When Watchdog sent it, while the status is sent, pending or
            not_booked; null otherwise.
      required:
        - kind
        - system_name
        - sent_at
      description: >-
        Where the invoice stands in its accounting system, as one status from
        sent to paid. Null when none holds, and after a failed send, whose
        reason is under transfer. The invoice and the transfer_stuck filter
        decide it alike.
    InvoiceApprover:
      type: object
      properties:
        user_id:
          type: string
        first_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        email:
          type:
            - string
            - 'null'
        approved:
          type: boolean
          description: >-
            This approver approved the invoice's current approval round. Several
            can have approved while the invoice waits for required_approvals.
        source:
          type: string
          enum:
            - person
            - rule
            - purchase_order
          description: >-
            Who added the approver: a rule, an order the invoice bills, or a
            person.
        rule_id:
          type:
            - string
            - 'null'
          format: uuid
          description: The rule that added the approver, if one did.
        rule_name:
          type:
            - string
            - 'null'
          description: The rule's name; null if none or deleted.
        purchase_order:
          $ref: '#/components/schemas/InvoiceApproverOrder'
        added_by:
          allOf:
            - $ref: '#/components/schemas/InvoicePerson'
            - description: >-
                The person who added the approver by hand; null for a rule, or
                when not recorded.
      required:
        - user_id
        - first_name
        - last_name
        - email
        - approved
        - source
        - rule_id
        - rule_name
        - purchase_order
        - added_by
    InvoiceApproverTeam:
      type: object
      properties:
        team_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Null when the team has been deleted since it decided.
        name:
          type:
            - string
            - 'null'
          description: Null when the team has been deleted since it decided.
        approved:
          type: boolean
          description: >-
            Someone approved for this team in the invoice's current approval
            round.
        approved_by:
          allOf:
            - $ref: '#/components/schemas/InvoicePerson'
            - description: Who approved for the team; null until someone has.
        source:
          type: string
          enum:
            - person
            - rule
            - purchase_order
          description: 'Who added the team: a rule, an order the invoice bills, or a person.'
        rule_id:
          type:
            - string
            - 'null'
          format: uuid
          description: The rule that added the team, if one did.
        rule_name:
          type:
            - string
            - 'null'
          description: The rule's name; null if none or deleted.
        purchase_order:
          $ref: '#/components/schemas/InvoiceApproverOrder'
        added_by:
          allOf:
            - $ref: '#/components/schemas/InvoicePerson'
            - description: >-
                The person who added the team by hand; null for a rule, or when
                not recorded.
        members:
          type: array
          items:
            type: object
            properties:
              user_id:
                type: string
              first_name:
                type:
                  - string
                  - 'null'
              last_name:
                type:
                  - string
                  - 'null'
              email:
                type:
                  - string
                  - 'null'
            required:
              - user_id
              - first_name
              - last_name
              - email
          description: >-
            Who is in the team now. Any of them with write access who can see
            the invoice may decide for it; the team counts as one approver.
      required:
        - team_id
        - name
        - approved
        - approved_by
        - source
        - rule_id
        - rule_name
        - purchase_order
        - added_by
        - members
    InvoiceLetterParty:
      type:
        - object
        - 'null'
      properties:
        name:
          type:
            - string
            - 'null'
        registration_number:
          type:
            - string
            - 'null'
        registration_country:
          type:
            - string
            - 'null'
          pattern: ^[A-Z]{2}$
        vat_number:
          type:
            - string
            - 'null'
        vat_country:
          type:
            - string
            - 'null'
          pattern: ^[A-Z]{2}$
      required:
        - name
        - registration_number
        - registration_country
        - vat_number
        - vat_country
      additionalProperties: false
    InvoiceLetterPayment:
      type: object
      properties:
        amount:
          type: string
          pattern: ^-?\d+(\.\d+)?$
        paid_on:
          type:
            - string
            - 'null'
          pattern: ^\d{4}-\d{2}-\d{2}$
      required:
        - amount
        - paid_on
      additionalProperties: false
    InvoiceLetterIssue:
      type: string
      enum:
        - charges_unknown
        - currency_unknown
        - sender_unknown
        - demand_mismatch
        - may_repeat_charge
        - sources_disagree
    InvoiceLetterSourceDiscrepancy:
      type: object
      properties:
        field:
          type: string
          enum:
            - amount_demanded
            - payment_reference
            - bank_account_number
        xml_value:
          type: string
        pdf_value:
          type: string
      required:
        - field
        - xml_value
        - pdf_value
    InvoiceLetterClaim:
      type: object
      properties:
        id:
          type: string
          format: uuid
        stated_invoice_number:
          type:
            - string
            - 'null'
        stated_issued_date:
          type:
            - string
            - 'null'
          format: date
        stated_due_date:
          type:
            - string
            - 'null'
          format: date
        stated_original_amount:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
        stated_outstanding_amount:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
        stated_payment_reference:
          type:
            - string
            - 'null'
        original_status:
          type: string
          enum:
            - matched
            - unmatched
            - unavailable
        original:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            invoice_number:
              type:
                - string
                - 'null'
            issued_date:
              type:
                - string
                - 'null'
              format: date
            accounting:
              type: object
              properties:
                status:
                  type: string
                  enum:
                    - settled
                    - outstanding
                    - unknown
                  description: Last known ledger balance, not proof of a cash payment.
                paid_on:
                  type:
                    - string
                    - 'null'
                  format: date
                read_at:
                  type:
                    - string
                    - 'null'
                  format: date-time
              required:
                - status
                - paid_on
                - read_at
          required:
            - id
            - invoice_number
            - issued_date
            - accounting
        accounting_lookup:
          $ref: '#/components/schemas/InvoiceLetterAccountingLookup'
        included_original_recovery:
          type: object
          properties:
            can_import:
              type: boolean
            suggested_pages:
              type:
                - object
                - 'null'
              properties:
                document_id:
                  type: string
                  format: uuid
                start_page:
                  type: integer
                  exclusiveMinimum: 0
                end_page:
                  type: integer
                  exclusiveMinimum: 0
              required:
                - document_id
                - start_page
                - end_page
            sources:
              type: array
              items:
                type: object
                properties:
                  document_id:
                    type: string
                    format: uuid
                  file_name:
                    type: string
                  page_count:
                    type:
                      - integer
                      - 'null'
                required:
                  - document_id
                  - file_name
                  - page_count
          required:
            - can_import
            - suggested_pages
            - sources
        can_link:
          type: boolean
      required:
        - id
        - stated_invoice_number
        - stated_issued_date
        - stated_due_date
        - stated_original_amount
        - stated_outstanding_amount
        - stated_payment_reference
        - original_status
        - original
        - accounting_lookup
        - included_original_recovery
        - can_link
    InvoiceLetterPrintedCharge:
      type: object
      properties:
        id:
          type: string
          format: uuid
        kind:
          type: string
          enum:
            - fee
            - interest
            - other_cost
        description:
          type: string
        amount:
          type: string
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
        claim_id:
          type:
            - string
            - 'null'
          format: uuid
      required:
        - id
        - kind
        - description
        - amount
        - claim_id
    InvoiceLetterLine:
      type: object
      properties:
        kind:
          type: string
          enum:
            - fee
            - interest
            - other_cost
        printed:
          type: string
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: What the letter prints of this kind.
        booked_earlier:
          type: string
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: What earlier letters chasing the same invoices already booked of it.
        to_book:
          type: string
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: 'What this letter books: its line.'
        line_item_id:
          type:
            - string
            - 'null'
          format: uuid
          description: That line; null when there is nothing new.
      required:
        - kind
        - printed
        - booked_earlier
        - to_book
        - line_item_id
    InvoiceLetterFlags:
      type: object
      properties:
        new_account:
          type: boolean
          description: >-
            It asks to be paid to an account that is not on the supplier's card
            in the accounting system: a known fraud pattern.
        settled_original:
          type: boolean
          description: An invoice it chases is already paid.
        missing_original:
          type: boolean
          description: An invoice it chases is not found in Watchdog.
      required:
        - new_account
        - settled_original
        - missing_original
    InvoicePerson:
      type:
        - object
        - 'null'
      properties:
        user_id:
          type: string
        first_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        email:
          type:
            - string
            - 'null'
      required:
        - user_id
        - first_name
        - last_name
        - email
      description: A person, by user ID and name.
    InvoiceAction:
      type: object
      properties:
        allowed:
          type: boolean
        reason:
          type:
            - string
            - 'null'
          enum:
            - deleted
            - not_now
            - read_only
            - sent_for_approval
            - in_accounting_system
            - approvers_only
            - ap_team_only
            - needs_company
            - needs_supplier
            - assigning_approvers
            - processing
            - null
          description: >-
            Why not; null when allowed. approvers_only: only its approvers, the
            AP team and admins. ap_team_only: only the AP team and admins.
      required:
        - allowed
        - reason
    TransferFailureCode:
      type: string
      enum:
        - unsupported_category
        - no_connection
        - connection_disabled
        - invoice_incomplete
        - not_coded
        - coding_from_other_connection
        - amounts_mismatch
        - company_mismatch
        - supplier_not_in_erp
        - supplier_link_unavailable
        - supplier_ambiguous
        - supplier_same_name
        - currency_unsupported
        - nothing_to_post
        - too_many_lines
        - dimension_unsupported
        - rounding_account_missing
        - sign_in_missing
        - sign_in_expired
        - sender_permission_missing
        - supplier_invoice_flow_off
        - duplicate_in_erp
        - ambiguous
        - changed_after_transfer
        - not_supplier_invoice
        - registered_differs
        - not_bookable
        - permission_missing
        - credentials_rejected
        - rejected
        - documents_rejected
        - documents_missing
        - reply_unreadable
        - provider_changed
        - unavailable
        - transfer_error
    InvoiceApproverOrder:
      type:
        - object
        - 'null'
      properties:
        id:
          type: string
          format: uuid
        number:
          type:
            - string
            - 'null'
      required:
        - id
        - number
      description: >-
        The purchase order whose invoice approvers added it (source
        purchase_order); null otherwise, or when the order is deleted or hidden
        from you.
    InvoiceLetterAccountingLookup:
      type: object
      properties:
        can_lookup:
          type: boolean
        connections:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
              name:
                type: string
            required:
              - id
              - name
          description: The Tripletex connections to choose from, when there are several.
        status:
          type:
            - string
            - 'null'
          enum:
            - searching
            - not_found
            - received
            - open
            - paid
            - failed
            - null
          description: >-
            The last lookup: searching, not_found, received (in Tripletex, not
            booked), open (booked, unpaid), paid (booked, settled) or failed.
            Null before the first lookup.
        looked_up_at:
          type:
            - string
            - 'null'
          format: date-time
        paid_on:
          type:
            - string
            - 'null'
          format: date
          description: >-
            With paid: the latest posted payment, when the posted payments
            settle it.
      required:
        - can_lookup
        - connections
        - status
        - looked_up_at
        - paid_on
  securitySchemes:
    ApiKeyBearer:
      type: http
      scheme: bearer
      description: >-
        Personal API key sent as a bearer token, together with
        X-Organization-Id. The key must have at least the access level the
        endpoint requires (read, write or admin).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.