> ## 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.

# Total invoice spend, overall or per supplier, recipient or month

> Counts invoices and totals their amounts (spend) per currency and in the organization currency, using the same filters as listInvoices; filter by supplier_ids for one supplier's spend. Totals are exact decimal strings and plain sums: an invoice without an amount adds nothing, and credit notes reduce spend. Use issued_from and issued_through to report a period. organization_currency converts amounts at each invoice's date; an invoice without an exchange rate for that date adds nothing there, though the per-currency totals include it. Add group_by to also get spend per supplier, recipient or issue month, for example the top suppliers by spend over a period or one supplier's spend per month (supplier_ids, group_by=month). Pass a group's key to supplier_ids or recipient_ids to list its invoices; for a month key (YYYY-MM), set issued_from and issued_through to the first and last day of that month.



## OpenAPI

````yaml /openapi.json get /v1/invoices/metrics
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/metrics:
    get:
      tags:
        - Invoices
      summary: Total invoice spend, overall or per supplier, recipient or month
      description: >-
        Counts invoices and totals their amounts (spend) per currency and in the
        organization currency, using the same filters as listInvoices; filter by
        supplier_ids for one supplier's spend. Totals are exact decimal strings
        and plain sums: an invoice without an amount adds nothing, and credit
        notes reduce spend. Use issued_from and issued_through to report a
        period. organization_currency converts amounts at each invoice's date;
        an invoice without an exchange rate for that date adds nothing there,
        though the per-currency totals include it. Add group_by to also get
        spend per supplier, recipient or issue month, for example the top
        suppliers by spend over a period or one supplier's spend per month
        (supplier_ids, group_by=month). Pass a group's key to supplier_ids or
        recipient_ids to list its invoices; for a month key (YYYY-MM), set
        issued_from and issued_through to the first and last day of that month.
      operationId: getInvoiceMetrics
      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.
        - name: fields
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
          style: form
          explode: false
          description: >-
            Return only these fields; use dots for nested fields, such as
            alert_scope.type. Fields: alert_scope, document_count, total_count,
            financially_invalid_count, alert_checked_count,
            alert_checkable_count, organization_currency, currencies, groups,
            next_cursor.
        - schema:
            type: array
            items:
              type: string
          required: false
          style: form
          explode: false
          name: view_ids
          in: query
        - schema:
            type: string
            minLength: 1
            maxLength: 200
            description: >-
              Invoice number, title, party name or a reference, ignoring case;
              eight or more digits, or a VAT number with its country prefix,
              also match an organization or VAT number. Under three characters
              match the start of the invoice number.
          required: false
          description: >-
            Invoice number, title, party name or a reference, ignoring case;
            eight or more digits, or a VAT number with its country prefix, also
            match an organization or VAT number. Under three characters match
            the start of the invoice number.
          name: search
          in: query
        - schema:
            type: string
            minLength: 1
            maxLength: 200
            description: Ignoring case; under three characters match its start.
          required: false
          description: Ignoring case; under three characters match its start.
          name: invoice_number
          in: query
        - schema:
            type: array
            items:
              type: string
          required: false
          style: form
          explode: false
          name: supplier_ids
          in: query
        - schema:
            type: array
            items:
              type: string
              format: uuid
            minItems: 1
            maxItems: 1000
          required: false
          style: form
          explode: false
          name: company_ids
          in: query
        - schema:
            type: boolean
            description: >-
              true: invoices waiting for a person to choose their company
              (company_id null; setInvoiceCompany); false: those with one. Only
              members with access to every company see them.
          required: false
          description: >-
            true: invoices waiting for a person to choose their company
            (company_id null; setInvoiceCompany); false: those with one. Only
            members with access to every company see them.
          name: without_company
          in: query
        - schema:
            type: array
            items:
              type: string
          required: false
          style: form
          explode: false
          name: recipient_ids
          in: query
        - schema:
            type: array
            items:
              type: string
              enum:
                - invoice
                - credit_note
                - self_billed_invoice
                - reminder
                - collection_notice
          required: false
          style: form
          explode: false
          name: categories
          in: query
        - schema:
            type: array
            items:
              type: string
          required: false
          style: form
          explode: false
          name: currency_codes
          in: query
        - schema:
            type: array
            items:
              type: string
              enum:
                - not_checked
                - checking
                - has_issues
                - clean
                - credited
            description: >-
              checking: a check is running; has_issues: open alerts; clean:
              checked, no open alerts; credited: covered by credit notes.
          required: false
          description: >-
            checking: a check is running; has_issues: open alerts; clean:
            checked, no open alerts; credited: covered by credit notes.
          style: form
          explode: false
          name: alert_statuses
          in: query
        - schema:
            type: array
            items:
              type: string
              enum:
                - high
                - mid
                - low
                - unknown
            description: Extraction confidence.
          required: false
          description: Extraction confidence.
          style: form
          explode: false
          name: confidence_levels
          in: query
        - schema:
            type: array
            items:
              type: string
              enum:
                - not_checkable
                - checking
                - not_checked
                - completed
                - incomplete
            description: >-
              completed: every matched agreement checked; incomplete: a check
              missing or failed; not_checkable: credit notes, and invoices fully
              reversed or without a document.
          required: false
          description: >-
            completed: every matched agreement checked; incomplete: a check
            missing or failed; not_checkable: credit notes, and invoices fully
            reversed or without a document.
          style: form
          explode: false
          name: check_statuses
          in: query
        - schema:
            type: boolean
            description: >-
              Invoices linked to a credit note, and credit notes linked to an
              invoice.
          required: false
          description: >-
            Invoices linked to a credit note, and credit notes linked to an
            invoice.
          name: has_recorded_match
          in: query
        - schema:
            type: string
            enum:
              - invoice
              - selected_agreements
            default: invoice
            description: >-
              invoice covers all of the invoice's checks and alerts;
              selected_agreements covers only the agreements in agreement_ids
              (required).
          required: false
          description: >-
            invoice covers all of the invoice's checks and alerts;
            selected_agreements covers only the agreements in agreement_ids
            (required).
          name: alert_scope
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
          required: false
          name: issued_from
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
          required: false
          name: issued_through
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
          required: false
          name: due_from
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
          required: false
          name: due_through
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
            description: >-
              Received (created_at) on or after this day, in the organization's
              time zone.
          required: false
          description: >-
            Received (created_at) on or after this day, in the organization's
            time zone.
          name: created_from
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
            description: As created_from, on or before.
          required: false
          description: As created_from, on or before.
          name: created_through
          in: query
        - schema:
            type: boolean
            description: The amounts add up (amounts.valid).
          required: false
          description: The amounts add up (amounts.valid).
          name: financially_valid
          in: query
        - schema:
            type: boolean
            description: A person has confirmed the extracted data.
          required: false
          description: A person has confirmed the extracted data.
          name: extraction_confirmed
          in: query
        - schema:
            type: boolean
          required: false
          name: review_recommended
          in: query
        - schema:
            type: array
            items:
              type: string
              format: uuid
            description: Invoices matched to any of these agreements.
          required: false
          description: Invoices matched to any of these agreements.
          style: form
          explode: false
          name: agreement_ids
          in: query
        - schema:
            type: boolean
            description: Matched to at least one agreement.
          required: false
          description: Matched to at least one agreement.
          name: has_agreement_match
          in: query
        - schema:
            type: boolean
            description: Alerts pending or accepted and not credited, even while checking.
          required: false
          description: Alerts pending or accepted and not credited, even while checking.
          name: has_open_alerts
          in: query
        - schema:
            type: boolean
            default: false
            description: true lists only soft-deleted invoices.
          required: false
          description: true lists only soft-deleted invoices.
          name: deleted
          in: query
        - schema:
            type: string
            enum:
              - inbox
              - needs_approval
              - on_hold
              - approved
              - rejected
            description: Superseded by phase and lifecycle_statuses.
          required: false
          description: Superseded by phase and lifecycle_statuses.
          name: stage
          in: query
        - schema:
            type: boolean
          required: false
          name: overdue
          in: query
        - schema:
            type: string
            enum:
              - me
            description: 'me: invoices where the caller is one of the approvers.'
          required: false
          description: 'me: invoices where the caller is one of the approvers.'
          name: approver
          in: query
        - schema:
            type: array
            items:
              type: string
              minLength: 1
              maxLength: 255
            description: >-
              Approvers include any of these members, by name or through a team,
              before and after they approve; who must act now is actionable.
          required: false
          description: >-
            Approvers include any of these members, by name or through a team,
            before and after they approve; who must act now is actionable.
          style: form
          explode: false
          name: approver_user_ids
          in: query
        - schema:
            type: string
            enum:
              - inbox
              - approval
              - payment
              - done
            description: As lifecycle.phase.
          required: false
          description: As lifecycle.phase.
          name: phase
          in: query
        - schema:
            type: array
            items:
              type: string
              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
            description: As lifecycle.status.
          required: false
          description: As lifecycle.status.
          style: form
          explode: false
          name: lifecycle_statuses
          in: query
        - schema:
            type: string
            enum:
              - me
            description: >-
              me: invoices whose next action is the caller's
              (lifecycle.next_action.mine).
          required: false
          description: >-
            me: invoices whose next action is the caller's
            (lifecycle.next_action.mine).
          name: actionable
          in: query
        - schema:
            type: array
            items:
              $ref: '#/components/schemas/TransferFailureCode'
            description: >-
              Last send to the accounting system failed with any of these
              (transfer.failure.code).
          required: false
          description: >-
            Last send to the accounting system failed with any of these
            (transfer.failure.code).
          style: form
          explode: false
          name: transfer_failures
          in: query
        - schema:
            type: boolean
            description: >-
              Sent to the accounting system, neither booked nor paid there, and
              rejected in its approval or waiting more than seven days.
          required: false
          description: >-
            Sent to the accounting system, neither booked nor paid there, and
            rejected in its approval or waiting more than seven days.
          name: transfer_stuck
          in: query
        - schema:
            type: string
            enum:
              - and
              - or
            default: and
            description: >-
              search, invoice_number, agreement_ids, created_from,
              created_through, review_recommended, deleted, stage, overdue,
              approver, approver_user_ids, phase, lifecycle_statuses,
              actionable, transfer_failures and transfer_stuck always apply.
          required: false
          description: >-
            search, invoice_number, agreement_ids, created_from,
            created_through, review_recommended, deleted, stage, overdue,
            approver, approver_user_ids, phase, lifecycle_statuses, actionable,
            transfer_failures and transfer_stuck always apply.
          name: join_operator
          in: query
        - schema:
            type: array
            items:
              type: string
              enum:
                - supplier_ids
                - recipient_ids
                - categories
                - currency_codes
                - confidence_levels
                - check_statuses
                - alert_statuses
                - agreement_ids
            description: List filters to invert.
          required: false
          description: List filters to invert.
          style: form
          explode: false
          name: not
          in: query
        - schema:
            type: string
            enum:
              - supplier
              - recipient
              - month
            description: >-
              Also return the totals per supplier, recipient or issue month in
              groups, one page at a time.
          required: false
          description: >-
            Also return the totals per supplier, recipient or issue month in
            groups, one page at a time.
          name: group_by
          in: query
        - schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 50
          required: false
          name: limit
          in: query
        - schema:
            type: string
            maxLength: 4096
          required: false
          name: cursor
          in: query
        - schema:
            type: string
            enum:
              - total_amount_excluding_vat
              - total_amount_including_vat
              - invoice_count
              - key
            default: total_amount_excluding_vat
            description: >-
              Group order, with group_by. Totals sort by their
              organization-currency value. key sorts by the group key, so months
              in calendar order.
          required: false
          description: >-
            Group order, with group_by. Totals sort by their
            organization-currency value. key sorts by the group key, so months
            in calendar order.
          name: sort
          in: query
        - schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
          required: false
          name: direction
          in: query
      responses:
        '200':
          description: >-
            Invoice counts and totals by currency, and with group_by a page of
            groups.
          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:
                alert_scope:
                  type: invoice
                  agreement_ids: null
                document_count: 2
                total_count: 2
                financially_invalid_count: 0
                alert_checked_count: 0
                alert_checkable_count: 2
                organization_currency:
                  currency_code: NOK
                  total_amount_excluding_vat: '2400.00'
                  total_amount_including_vat: '3000.00'
                  alert_checked_amount: '0'
                  alert_checkable_amount: '3000.00'
                  alert_checked_amount_excluding_vat: '0'
                  alert_checkable_amount_excluding_vat: '2400.00'
                currencies:
                  - currency_code: NOK
                    invoice_count: 1
                    alert_checked_count: 0
                    alert_checkable_count: 1
                    alert_checked_amount: '0'
                    alert_checkable_amount: '125.00'
                    alert_checked_amount_excluding_vat: '0'
                    alert_checkable_amount_excluding_vat: '100.00'
                    total_amount_excluding_vat: '100.00'
                    total_amount_including_vat: '125.00'
                  - currency_code: EUR
                    invoice_count: 1
                    alert_checked_count: 0
                    alert_checkable_count: 1
                    alert_checked_amount: '0'
                    alert_checkable_amount: '250.00'
                    alert_checked_amount_excluding_vat: '0'
                    alert_checkable_amount_excluding_vat: '200.00'
                    total_amount_excluding_vat: '200.00'
                    total_amount_including_vat: '250.00'
              schema:
                $ref: '#/components/schemas/InvoiceMetricsResult'
        '400':
          description: >-
            The request is invalid. details lists up to 20 field errors. Request
            bodies are limited to 2 MiB.
          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: >-
                    The request is invalid. details lists up to 20 field errors.
                    Request bodies are limited to 2 MiB.
                  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: >-
            One or more selected Views have invalid saved filter rules. Update
            the View filters 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.
          content:
            application/json:
              example:
                error:
                  code: conflict
                  message: >-
                    One or more selected Views have invalid saved filter rules.
                    Update the View filters before retrying.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_conflict'
        '422':
          description: >-
            More than 1,000 invoices match search or invoice_number. Narrow the
            search or use other filters.
          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: search_too_broad
                  message: >-
                    More than 1,000 invoices match search or invoice_number.
                    Narrow the search or use other filters.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_search_too_broad'
        '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:
    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
    InvoiceMetricsResult:
      type: object
      properties:
        alert_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
        document_count:
          type: integer
          description: >-
            Visible document rows matching this selection, including reminders
            and collection notices.
        total_count:
          type: integer
          description: Purchase invoice and credit-note count, excluding letter rows.
        financially_invalid_count:
          type: integer
        alert_checked_count:
          type: integer
        alert_checkable_count:
          type: integer
        organization_currency:
          type: object
          properties:
            currency_code:
              type: string
            total_amount_excluding_vat:
              type: string
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: >-
                Total excluding VAT of all matching invoices (spend; credit
                notes reduce it).
              example: '1250.00'
            total_amount_including_vat:
              type: string
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: Total including VAT of all matching invoices.
              example: '1250.00'
            alert_checked_amount:
              type: string
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: Total including VAT of checked invoices.
              example: '1250.00'
            alert_checkable_amount:
              type: string
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: Total including VAT of checkable invoices.
              example: '1250.00'
            alert_checked_amount_excluding_vat:
              type: string
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: Total excluding VAT of checked invoices.
              example: '1250.00'
            alert_checkable_amount_excluding_vat:
              type: string
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: Total excluding VAT of checkable invoices.
              example: '1250.00'
          required:
            - currency_code
            - total_amount_excluding_vat
            - total_amount_including_vat
            - alert_checked_amount
            - alert_checkable_amount
            - alert_checked_amount_excluding_vat
            - alert_checkable_amount_excluding_vat
          description: >-
            Totals converted to the organization currency at each invoice's
            date, rounded to cents. An invoice without an amount or exchange
            rate adds nothing.
        currencies:
          type: array
          items:
            type: object
            properties:
              currency_code:
                type:
                  - string
                  - 'null'
              invoice_count:
                type: integer
              alert_checked_count:
                type: integer
              alert_checkable_count:
                type: integer
              alert_checked_amount:
                type: string
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Exact decimal as a string. Parse it as a decimal, not a
                  floating-point number.
                example: '1250.00'
              alert_checkable_amount:
                type: string
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Exact decimal as a string. Parse it as a decimal, not a
                  floating-point number.
                example: '1250.00'
              alert_checked_amount_excluding_vat:
                type: string
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Exact decimal as a string. Parse it as a decimal, not a
                  floating-point number.
                example: '1250.00'
              alert_checkable_amount_excluding_vat:
                type: string
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Exact decimal as a string. Parse it as a decimal, not a
                  floating-point number.
                example: '1250.00'
              total_amount_excluding_vat:
                type: string
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Exact decimal as a string. Parse it as a decimal, not a
                  floating-point number.
                example: '1250.00'
              total_amount_including_vat:
                type: string
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Exact decimal as a string. Parse it as a decimal, not a
                  floating-point number.
                example: '1250.00'
            required:
              - currency_code
              - invoice_count
              - alert_checked_count
              - alert_checkable_count
              - alert_checked_amount
              - alert_checkable_amount
              - alert_checked_amount_excluding_vat
              - alert_checkable_amount_excluding_vat
              - total_amount_excluding_vat
              - total_amount_including_vat
        groups:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceGroup'
          description: 'With group_by: a page of groups with their invoice counts and spend.'
        next_cursor:
          type:
            - string
            - 'null'
          description: >-
            With group_by: the cursor for the next page of groups; null at the
            end.
      required:
        - alert_scope
        - document_count
        - total_count
        - financially_invalid_count
        - alert_checked_count
        - alert_checkable_count
        - organization_currency
        - currencies
    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_search_too_broad:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - search_too_broad
            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
    InvoiceGroup:
      type: object
      properties:
        group_by:
          type: string
          enum:
            - supplier
            - recipient
            - month
        key:
          type:
            - string
            - 'null'
          description: >-
            The group's filter value: a supplier or recipient ID (supplier_ids,
            recipient_ids), or the issue month as YYYY-MM (issued_from and
            issued_through set to its first and last day). Null means no
            supplier, recipient or issue date.
        resource:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            name:
              type:
                - string
                - 'null'
          required:
            - id
            - name
          description: >-
            The group's supplier or recipient with its current name. Null for
            month groups.
        invoice_count:
          type: integer
        organization_currency:
          type: object
          properties:
            currency_code:
              type: string
            total_amount_excluding_vat:
              type: string
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: >-
                Spend: the known totals excluding VAT; credit notes reduce it.
                Sort by it to rank groups.
              example: '1250.00'
            total_amount_including_vat:
              type: string
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: >-
                Exact decimal as a string. Parse it as a decimal, not a
                floating-point number.
              example: '1250.00'
          required:
            - currency_code
            - total_amount_excluding_vat
            - total_amount_including_vat
          description: >-
            Totals converted to the organization currency at each invoice's
            date, rounded to cents.
        currencies:
          type: array
          items:
            type: object
            properties:
              currency_code:
                type:
                  - string
                  - 'null'
              invoice_count:
                type: integer
              total_amount_excluding_vat:
                type: string
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Exact decimal as a string. Parse it as a decimal, not a
                  floating-point number.
                example: '1250.00'
              total_amount_including_vat:
                type: string
                maxLength: 100
                pattern: ^-?\d+(?:\.\d+)?$
                description: >-
                  Exact decimal as a string. Parse it as a decimal, not a
                  floating-point number.
                example: '1250.00'
            required:
              - currency_code
              - invoice_count
              - total_amount_excluding_vat
              - total_amount_including_vat
      required:
        - group_by
        - key
        - resource
        - invoice_count
        - organization_currency
        - currencies
  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.