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

# Start compliance checks

> Checks invoices against their matched agreements and purchase orders. A check that completes closes its pair's current alerts as replaced, keeping their decisions for reference, and opens its findings as new pending alerts; a check that fails changes nothing. One agreement check workflow runs per agreement. Pairs an open claim holds, pairs already being checked and invoices that cannot be checked are always left out; the preview's exclusions count them. One request starts at most 5,000 agreement checks across 50 agreements, 500 purchase-order checks and 500 duplicate checks, all or nothing; larger selections return 409. A workflow_run_ids entry means a check started, not that it finished: follow each workflow run. Send an Idempotency-Key to repeat a request safely after a lost response.



## OpenAPI

````yaml /openapi.json post /v1/checks
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/checks:
    post:
      tags:
        - Compliance checks
      summary: Start compliance checks
      description: >-
        Checks invoices against their matched agreements and purchase orders. A
        check that completes closes its pair's current alerts as replaced,
        keeping their decisions for reference, and opens its findings as new
        pending alerts; a check that fails changes nothing. One agreement check
        workflow runs per agreement. Pairs an open claim holds, pairs already
        being checked and invoices that cannot be checked are always left out;
        the preview's exclusions count them. One request starts at most 5,000
        agreement checks across 50 agreements, 500 purchase-order checks and 500
        duplicate checks, all or nothing; larger selections return 409. A
        workflow_run_ids entry means a check started, not that it finished:
        follow each workflow run. Send an Idempotency-Key to repeat a request
        safely after a lost response.
      operationId: startChecks
      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: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            minLength: 1
            maxLength: 200
            pattern: ^[\x21-\x7e]+$
          description: >-
            Optional protection for safely retrying a request after a timeout or
            lost response. Choose a unique value (for example, a UUID) for each
            action and reuse it with the same input when retrying. Omit it for a
            normal request.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                scope:
                  oneOf:
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - invoices
                        invoice_ids:
                          type: array
                          items:
                            type: string
                            format: uuid
                          minItems: 1
                          maxItems: 1000
                          description: >-
                            Up to 1,000 invoices. Every agreement matched to one
                            is in scope, and the purchase order accepted for
                            one.
                      required:
                        - type
                        - invoice_ids
                      additionalProperties: false
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - agreements
                        filter:
                          $ref: '#/components/schemas/AgreementFilter'
                        agreement_ids:
                          type: array
                          items:
                            type: string
                            format: uuid
                          maxItems: 1000
                        excluded_agreement_ids:
                          type: array
                          items:
                            type: string
                            format: uuid
                          maxItems: 1000
                          default: []
                        agreement_version_status:
                          type: string
                          enum:
                            - current
                            - older
                          description: >-
                            The alert assessed the current agreement version or
                            an older one; an unknown version or no agreement
                            matches neither.
                      required:
                        - type
                      additionalProperties: false
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - topics
                        agreement_id:
                          type: string
                          format: uuid
                        topic_ids:
                          type: array
                          items:
                            type: string
                            format: uuid
                          maxItems: 1000
                        include_uncategorized:
                          type: boolean
                          default: false
                        agreement_version_status:
                          type: string
                          enum:
                            - current
                            - older
                          description: >-
                            The alert assessed the current agreement version or
                            an older one; an unknown version or no agreement
                            matches neither.
                      required:
                        - type
                        - agreement_id
                        - topic_ids
                      additionalProperties: false
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - retry
                        workflow_run_id:
                          type: string
                          format: uuid
                      required:
                        - type
                        - workflow_run_id
                      additionalProperties: false
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - purchase_orders
                        purchase_order_ids:
                          type: array
                          items:
                            type: string
                            format: uuid
                          minItems: 1
                          maxItems: 1000
                          description: >-
                            Up to 1,000 purchase orders. Checks their accepted
                            invoices against them only.
                      required:
                        - type
                        - purchase_order_ids
                      additionalProperties: false
                  description: >-
                    agreements: agreement_ids, or every agreement filter matches
                    (the whole collection, not a page), minus
                    excluded_agreement_ids; at most 1,000. topics: the invoices
                    behind some topics of one agreement, include_uncategorized
                    adding its alerts without a topic; a pair is handled as a
                    whole, so its alerts in other topics change too
                    (other_topic_alert_count). retry: the failed or cancelled
                    items of an agreement check, with mode again.
                mode:
                  type: string
                  enum:
                    - outstanding
                    - again
                  default: outstanding
                  description: >-
                    outstanding: only pairs (invoice–agreement or
                    invoice–purchase order) without a completed check. again:
                    completed pairs too, replacing their alerts; on an invoices
                    scope it also checks each invoice for duplicates again,
                    replacing its duplicate alerts.
                invoices:
                  oneOf:
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - all
                        excluded_invoice_ids:
                          type: array
                          items:
                            type: string
                            format: uuid
                          maxItems: 5000
                          default: []
                          description: >-
                            Invoices left out of an otherwise complete
                            selection.
                      required:
                        - type
                      additionalProperties: false
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - sample
                        seed:
                          type: string
                          format: uuid
                        invoice_ids:
                          type: array
                          items:
                            type: string
                            format: uuid
                          maxItems: 10
                          description: >-
                            Invoice IDs returned by the preview, pinned until
                            the user changes the selection.
                      required:
                        - type
                        - seed
                      additionalProperties: false
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - selected
                        invoice_ids:
                          type: array
                          items:
                            type: string
                            format: uuid
                          maxItems: 5000
                      required:
                        - type
                        - invoice_ids
                      additionalProperties: false
                  default:
                    type: all
                    excluded_invoice_ids: []
                  description: >-
                    Which of the scope’s invoices to take: all (minus
                    exclusions), a sample of ten, or a hand-picked set.
                issued_from:
                  type: string
                  format: date
                  description: Only invoices issued on or after this date.
                issued_through:
                  type: string
                  format: date
                  description: Only invoices issued on or before this date.
                company_ids:
                  type: array
                  items:
                    type: string
                    format: uuid
                  minItems: 1
                  maxItems: 1000
                  description: >-
                    Only these workspace companies: their invoices under
                    agreements covering them, as for a member with access to
                    just those companies. Omit for every company the caller can
                    access. An unknown or inaccessible company is 404.
                preview:
                  type: boolean
                  default: false
                  description: >-
                    true: return what the command would do and its fingerprint,
                    changing nothing.
                fingerprint:
                  type: string
                  minLength: 64
                  maxLength: 64
                  description: >-
                    The fingerprint of a preview. When sent, the command runs
                    only if the selection still resolves to exactly what was
                    previewed; omit it to act on the current state.
              required:
                - scope
              additionalProperties: false
      responses:
        '200':
          description: >-
            With preview: true, the preview (CheckSelectionPreview). Otherwise a
            repeated Idempotency-Key: the original result, with Location naming
            its first workflow run.
          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.
            Location:
              schema:
                type: string
              required: false
              description: Relative URL of the created or accepted resource.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/CheckSelectionPreview'
                  - $ref: '#/components/schemas/CheckSelectionResult'
        '202':
          description: Checks started. Location names the first workflow run.
          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.
            Location:
              schema:
                type: string
              required: false
              description: Relative URL of the created or accepted resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckSelectionResult'
        '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: >-
            conflict: the selection changed since the preview, it is too large,
            the run cannot be retried, or the Idempotency-Key was used for a
            different request. nothing_to_check: no pair in the selection can be
            checked. Nothing was started.
          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: >-
                    conflict: the selection changed since the preview, it is too
                    large, the run cannot be retried, or the Idempotency-Key was
                    used for a different request. nothing_to_check: no pair in
                    the selection can be checked. Nothing was started.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_conflict_nothing_to_check'
        '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: >-
            The checks were admitted but not every start was confirmed. Location
            names an unconfirmed run, and the Idempotency-Key header carries the
            key (the generated one if you sent none); repeat the request with
            that key rather than a new one.
          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.
            Location:
              schema:
                type: string
              required: false
              description: Relative URL of the created or accepted resource.
            Retry-After:
              schema:
                type: string
                example: '60'
              required: false
              description: Seconds to wait before retrying the request.
            Idempotency-Key:
              schema:
                type: string
              required: false
              description: The key to repeat this request with.
          content:
            application/json:
              example:
                error:
                  code: service_unavailable
                  message: >-
                    The checks were admitted but not every start was confirmed.
                    Location names an unconfirmed run, and the Idempotency-Key
                    header carries the key (the generated one if you sent none);
                    repeat the request with that key rather than a new one.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_service_unavailable'
      security:
        - ApiKeyBearer: []
components:
  schemas:
    AgreementFilter:
      type: object
      properties:
        view_ids:
          type: array
          items:
            type: string
        ids:
          type: array
          items:
            type: string
            format: uuid
        renewal_action_kinds:
          type: array
          items:
            type: string
            enum:
              - cancel_by
              - renew_by
              - automatic_notice
              - missing_details
              - none
          description: >-
            The next renewal action. cancel_by: renews unless cancelled by the
            deadline; renew_by: ends unless renewed by it; automatic_notice: no
            expiration date, ends with the notice period, so no deadline;
            missing_details: no deadline can be computed; none: no renewal left.
        renewal_deadline_from:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
        renewal_deadline_through:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
        upcoming_through:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          description: >-
            A renewal deadline or expiration date from today (organization's
            timezone) through this date: what must be cancelled, renewed or will
            end soon.
        search:
          type: string
          minLength: 1
          maxLength: 200
          description: Agreement title or a supplier name.
        statuses:
          type: array
          items:
            type: string
            enum:
              - draft
              - active
              - archived
          description: >-
            draft: being set up; active: invoices are checked against it;
            archived: no longer checked. Says nothing about whether the term is
            in force: use valid_on for that.
        supplier_ids:
          type: array
          items:
            type: string
            format: uuid
        recipient_ids:
          type: array
          items:
            type: string
            format: uuid
          description: Includes agreements for any recipient.
        company_ids:
          type: array
          items:
            type: string
            format: uuid
          minItems: 1
          maxItems: 1000
          description: >-
            Agreements that cover any of these companies. A shared agreement
            appears once, with its alert numbers and counts for those companies'
            invoices only.
        tag_ids:
          type: array
          items:
            type: string
            format: uuid
        owner_user_ids:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 200
            pattern: ^[A-Za-z0-9_-]+$
          description: Case-sensitive.
        has_owner:
          type: boolean
          description: >-
            false: agreements with no owner; true: agreements with an owner.
            Removing a member unassigns their agreements. Combined with
            owner_user_ids, false matches nothing.
        auto_check_new_invoices:
          type: boolean
          description: >-
            true: agreements whose new matching invoices are checked
            automatically; false: those checked only when someone runs a check.
        has_alert_verdicts:
          type: array
          items:
            type: string
            enum:
              - pending
              - accepted
              - dismissed
              - skipped
          description: >-
            At least one alert with any of these verdicts; with
            has_alert_credited, on the same alert.
        has_alert_credited:
          type: boolean
          description: At least one alert (not) credited.
        review_status:
          type: string
          enum:
            - to_review
            - reviewed
          description: >-
            to_review: at least one live alert still to review (pending).
            reviewed: live alerts, every one of them confirmed, a false alarm or
            unsure. Agreements without live alerts match neither.
        effective_from:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          description: Excludes agreements without one.
        effective_through:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
        expiration_from:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          description: Excludes agreements without one.
        expiration_through:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
        valid_on:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          description: >-
            In force on this date: effective on or before it and expiring on or
            after it. A missing date counts as open-ended.
        join_operator:
          type: string
          enum:
            - and
            - or
          description: or combines only supplier_ids and tag_ids.
        not:
          type: array
          items:
            type: string
            enum:
              - statuses
              - supplier_ids
              - recipient_ids
              - tag_ids
              - owner_user_ids
              - renewal_action_kinds
          description: List filters to invert.
      additionalProperties: false
    CheckSelectionPreview:
      type: object
      properties:
        options:
          type: object
          properties:
            outstanding:
              type: object
              properties:
                invoice_count:
                  type: integer
                  description: >-
                    Every invoice this mode could check in the scope, before
                    exclusions or sampling.
                replaced_alert_count:
                  type: integer
                  description: >-
                    Current alerts that a successful check replaces, after
                    exclusions and sampling.
                handled_alert_count:
                  type: integer
                  description: >-
                    The replaced alerts someone has reviewed: confirmed, false
                    alarm or unsure.
              required:
                - invoice_count
                - replaced_alert_count
                - handled_alert_count
            again:
              type: object
              properties:
                invoice_count:
                  type: integer
                  description: >-
                    Every invoice this mode could check in the scope, before
                    exclusions or sampling.
                replaced_alert_count:
                  type: integer
                  description: >-
                    Current alerts that a successful check replaces, after
                    exclusions and sampling.
                handled_alert_count:
                  type: integer
                  description: >-
                    The replaced alerts someone has reviewed: confirmed, false
                    alarm or unsure.
              required:
                - invoice_count
                - replaced_alert_count
                - handled_alert_count
          required:
            - outstanding
            - again
          description: >-
            What each check mode would run in this scope, whichever mode is
            selected.
        fingerprint:
          type: string
        sample_invoice_ids:
          type:
            - array
            - 'null'
          items:
            type: string
            format: uuid
        agreements:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
              title:
                type:
                  - string
                  - 'null'
              reasons:
                type: array
                items:
                  type: string
                  enum:
                    - inactive
                    - missing_title
                    - missing_supplier
                    - missing_content
                    - documents_not_ready
                    - documents_too_large
              check_count:
                type: integer
            required:
              - id
              - title
              - reasons
              - check_count
        invoice_count:
          type: integer
        check_count:
          type: integer
        purchase_order_check_count:
          type: integer
          description: >-
            Invoice–purchase order checks the selection runs, beside the
            agreement checks.
        duplicate_check_count:
          type: integer
          description: >-
            Invoices the selection checks for duplicates again: with mode again
            on an invoices scope, each of its invoices.
        exceeds_limit:
          type: boolean
        maximum_checks:
          type: integer
        maximum_runs:
          type: integer
        exclusions:
          type: array
          items:
            type: object
            properties:
              reason:
                type: string
                enum:
                  - not_ready
                  - not_checkable
                  - claimed
                  - running
                  - completed
              count:
                type: integer
            required:
              - reason
              - count
          description: >-
            Invoice–agreement pairs in scope that the selected mode leaves out,
            by reason.
        other_topic_alert_count:
          type: integer
          description: Replaced alerts that belong to topics outside a topic scope.
      required:
        - options
        - fingerprint
        - sample_invoice_ids
        - agreements
        - invoice_count
        - check_count
        - purchase_order_check_count
        - duplicate_check_count
        - exceeds_limit
        - maximum_checks
        - maximum_runs
        - exclusions
        - other_topic_alert_count
    CheckSelectionResult:
      type: object
      properties:
        agreements:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
              title:
                type:
                  - string
                  - 'null'
              check_count:
                type: integer
            required:
              - id
              - title
              - check_count
        mode:
          type: string
          enum:
            - outstanding
            - again
        workflow_run_ids:
          type: array
          items:
            type: string
            format: uuid
          description: >-
            One agreement check per agreement. Started, not finished: follow
            each run.
        invoice_count:
          type: integer
        check_count:
          type: integer
        purchase_order_check_count:
          type: integer
          description: >-
            Invoice–purchase order checks, already complete when this returns:
            they compare stored terms and need no workflow.
        duplicate_check_count:
          type: integer
          description: >-
            Invoices checked for duplicates again, already complete when this
            returns. Each check replaces that invoice's duplicate alerts, so a
            decided one comes back pending; the supplier's other invoices of its
            number keep theirs.
      required:
        - agreements
        - mode
        - workflow_run_ids
        - invoice_count
        - check_count
        - purchase_order_check_count
        - duplicate_check_count
    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_nothing_to_check:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - conflict
                - nothing_to_check
            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
  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.