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

# Create an alert

> Records a finding on an invoice, against an agreement the invoice is matched to. The alert counts, groups and can be claimed like any other; re-checks and check resets keep it. Without topic_id, the agreement's topics are reconciled so it gets grouped. Repeating the request with the same Idempotency-Key returns the original alert with 200.



## OpenAPI

````yaml /openapi-preview.json post /v1/alerts
openapi: 3.1.0
info:
  title: Watchdog API
  version: 1.0.0
  description: >-
    The Watchdog API is served from https://api-canary.watchdog.no until it
    moves to 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-canary.watchdog.no
    description: Watchdog API
security: []
paths:
  /v1/alerts:
    post:
      tags:
        - Alerts
      summary: Create an alert
      description: >-
        Records a finding on an invoice, against an agreement the invoice is
        matched to. The alert counts, groups and can be claimed like any other;
        re-checks and check resets keep it. Without topic_id, the agreement's
        topics are reconciled so it gets grouped. Repeating the request with the
        same Idempotency-Key returns the original alert with 200.
      operationId: createAlert
      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:
                invoice_id:
                  type: string
                  format: uuid
                agreement_id:
                  type: string
                  format: uuid
                  description: >-
                    The agreement the finding is about. The invoice must be
                    matched to it.
                invoice_item_id:
                  type:
                    - string
                    - 'null'
                  format: uuid
                  description: >-
                    The invoice line the finding is about. Required for
                    modify_item, and only then.
                correction_type:
                  type: string
                  enum:
                    - modify_item
                    - modify_invoice
                    - add_item
                  description: >-
                    modify_item: a billed line is wrong. add_item: a line is
                    missing. modify_invoice: the finding concerns the whole
                    invoice. Defaults to modify_item with an invoice_item_id and
                    modify_invoice without.
                title:
                  type: string
                  minLength: 1
                  maxLength: 500
                explanation:
                  type:
                    - string
                    - 'null'
                  maxLength: 20000
                impact_amount:
                  type:
                    - string
                    - 'null'
                  maxLength: 100
                  pattern: ^-?\d+(?:\.\d+)?$
                  description: >-
                    The amount the invoice is wrong by, in the invoice currency:
                    positive when it charges more than agreed. Omit it on a line
                    or missing-line alert to calculate it from expected pricing;
                    an invoice-level alert has no line to compare with, so send
                    it there.
                confidence:
                  type: object
                  properties:
                    level:
                      type: string
                      enum:
                        - high
                        - mid
                        - low
                    reason:
                      type:
                        - string
                        - 'null'
                      maxLength: 2000
                  required:
                    - level
                  additionalProperties: false
                questions:
                  type: array
                  items:
                    type: string
                    maxLength: 2000
                  maxItems: 50
                expected:
                  type: object
                  properties:
                    base_price:
                      type:
                        - string
                        - 'null'
                      maxLength: 100
                      pattern: ^-?\d+(?:\.\d+)?$
                    quantity:
                      type:
                        - string
                        - 'null'
                      maxLength: 100
                      pattern: ^-?\d+(?:\.\d+)?$
                    discount:
                      type:
                        - string
                        - 'null'
                      maxLength: 100
                      pattern: ^-?\d+(?:\.\d+)?$
                    surcharge:
                      type:
                        - string
                        - 'null'
                      maxLength: 100
                      pattern: ^-?\d+(?:\.\d+)?$
                    adjustment_uplift:
                      type:
                        - string
                        - 'null'
                      maxLength: 100
                      pattern: ^-?\d+(?:\.\d+)?$
                    price_explanation:
                      type:
                        - string
                        - 'null'
                      maxLength: 20000
                    adjustment_explanation:
                      type:
                        - string
                        - 'null'
                      maxLength: 20000
                    product_code:
                      type:
                        - string
                        - 'null'
                      maxLength: 2000
                    description:
                      type:
                        - string
                        - 'null'
                      maxLength: 20000
                    unit:
                      type:
                        - string
                        - 'null'
                      maxLength: 2000
                  additionalProperties: false
                citations:
                  type: array
                  items:
                    type: object
                    properties:
                      source_ref:
                        type: integer
                        exclusiveMinimum: 0
                        maximum: 1000
                      citation:
                        anyOf:
                          - type: object
                            properties:
                              id:
                                type: string
                                format: uuid
                            required:
                              - id
                            additionalProperties: false
                          - type: object
                            properties:
                              source:
                                anyOf:
                                  - type: object
                                    properties:
                                      source_type:
                                        type: string
                                        enum:
                                          - document
                                      document_id:
                                        type: string
                                        format: uuid
                                    required:
                                      - source_type
                                      - document_id
                                    additionalProperties: false
                                  - type: object
                                    properties:
                                      source_type:
                                        type: string
                                        enum:
                                          - web
                                      url:
                                        type: string
                                        maxLength: 20000
                                    required:
                                      - source_type
                                      - url
                                    additionalProperties: false
                                  - type: object
                                    properties:
                                      source_type:
                                        type: string
                                        enum:
                                          - agreement_items
                                      item_ids:
                                        type: array
                                        items:
                                          type: string
                                          format: uuid
                                        minItems: 1
                                        maxItems: 100
                                    required:
                                      - source_type
                                      - item_ids
                                    additionalProperties: false
                                  - type: object
                                    properties:
                                      source_type:
                                        type: string
                                        enum:
                                          - user_context
                                      text:
                                        type: string
                                        minLength: 1
                                        maxLength: 20000
                                    required:
                                      - source_type
                                      - text
                                    additionalProperties: false
                              quote:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 20000
                              text:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 20000
                              page:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 20000
                              section_title:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 20000
                              context_before:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 20000
                              context_after:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 20000
                              title:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 20000
                            required:
                              - source
                            additionalProperties: false
                    required:
                      - source_ref
                      - citation
                    additionalProperties: false
                  maxItems: 100
                  description: >-
                    Sources for the finding, numbered by source_ref. Inline
                    markers such as [1] in the text refer to them. Each citation
                    is a new source or an existing citation id.
                topic_id:
                  type:
                    - string
                    - 'null'
                  format: uuid
                  description: >-
                    A topic of the same agreement to put the alert in. Without
                    one, the agreement's topics are reconciled so the alert gets
                    grouped.
              required:
                - invoice_id
                - agreement_id
                - title
              additionalProperties: false
            example:
              invoice_id: 6f1d2c1e-8b6a-4a51-9d7e-2f0c7b1f4a10
              agreement_id: b3f4c2d1-0a9e-4c6b-8f7d-5e4a3b2c1d0e
              correction_type: modify_invoice
              title: Order size discount not applied
              explanation: Orders above USD 25,000 get a 5% discount [1].
              impact_amount: '966.00'
              confidence:
                level: high
                reason: The order total is above the threshold.
              citations:
                - source_ref: 1
                  citation:
                    source:
                      source_type: document
                      document_id: 0d9c8b7a-6f5e-4d3c-2b1a-0f9e8d7c6b5a
                    quote: Orders above USD 25,000 receive a 5% discount.
      responses:
        '200':
          description: The alert.
          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.
            ETag:
              schema:
                type: string
              required: true
              description: >-
                Version of the resource. Send it as If-Match to change it only
                if it has not changed since.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Alert'
        '201':
          description: The alert.
          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.
            ETag:
              schema:
                type: string
              required: true
              description: >-
                Version of the resource. Send it as If-Match to change it only
                if it has not changed since.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Alert'
        '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:
              schema:
                $ref: '#/components/schemas/Error_validation_error'
              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
        '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:
              schema:
                $ref: '#/components/schemas/Error_invalid_token'
              example:
                error:
                  code: invalid_token
                  message: The bearer token is missing or invalid.
                  request_id: req_example
        '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:
              schema:
                $ref: >-
                  #/components/schemas/Error_forbidden_token_disabled_organization_required_insufficient_role_mfa_required
              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
        '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:
              schema:
                $ref: '#/components/schemas/Error_not_found'
              example:
                error:
                  code: not_found
                  message: The resource does not exist in the current organization.
                  request_id: req_example
        '409':
          description: >-
            The invoice is not matched to the agreement or lacks a supplier or
            currency, the topic belongs to another agreement, or the
            Idempotency-Key was used with different input.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error_conflict'
              example:
                error:
                  code: conflict
                  message: >-
                    The invoice is not matched to the agreement or lacks a
                    supplier or currency, the topic belongs to another
                    agreement, or the Idempotency-Key was used with different
                    input.
                  request_id: req_example
        '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:
              schema:
                $ref: '#/components/schemas/Error_rate_limit_exceeded'
              example:
                error:
                  code: rate_limit_exceeded
                  message: >-
                    Too many requests. Wait for the Retry-After delay before
                    retrying.
                  request_id: req_example
        '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:
              schema:
                $ref: '#/components/schemas/Error_internal_error'
              example:
                error:
                  code: internal_error
                  message: >-
                    Unexpected server failure. Include the request ID when
                    contacting support.
                  request_id: req_example
        '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:
              schema:
                $ref: '#/components/schemas/Error_service_unavailable'
              example:
                error:
                  code: service_unavailable
                  message: >-
                    Temporarily unavailable. Retry after the Retry-After delay,
                    when provided.
                  request_id: req_example
      security:
        - ApiKeyBearer: []
components:
  schemas:
    Alert:
      allOf:
        - $ref: '#/components/schemas/AlertSummary'
        - type: object
          properties:
            questions:
              type: array
              items:
                type: string
            price_item_ids:
              type: array
              items:
                type: string
                format: uuid
              description: >-
                Agreement prices the alert relies on. Read them with GET
                /v1/agreements/{id}/price-items?ids=.
            expected:
              type: object
              properties:
                base_price:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                quantity:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                discount:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                surcharge:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                adjustment_uplift:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                net_price:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                  readOnly: true
                  description: Calculated from the expected pricing fields.
                total:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                  readOnly: true
                  description: Calculated from expected net price and quantity.
                price_explanation:
                  type:
                    - string
                    - 'null'
                adjustment_explanation:
                  type:
                    - string
                    - 'null'
                product_code:
                  type:
                    - string
                    - 'null'
                description:
                  type:
                    - string
                    - 'null'
                unit:
                  type:
                    - string
                    - 'null'
              required:
                - base_price
                - quantity
                - discount
                - surcharge
                - adjustment_uplift
                - net_price
                - total
                - price_explanation
                - adjustment_explanation
                - product_code
                - description
                - unit
            invoiced:
              type: object
              properties:
                base_price:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                net_price:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                quantity:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                discount:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                surcharge:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
                total:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
              required:
                - base_price
                - net_price
                - quantity
                - discount
                - surcharge
                - total
              readOnly: true
              description: Invoiced pricing when the alert was created.
            evidence:
              type: object
              properties:
                citations:
                  type: array
                  items:
                    anyOf:
                      - type: object
                        properties:
                          source_ref:
                            type: integer
                            exclusiveMinimum: 0
                          citation_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          title:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          quote:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          text:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          verification:
                            type:
                              - string
                              - 'null'
                            enum:
                              - verified
                              - corrected
                              - recovered
                              - unverified
                              - null
                          verification_score:
                            type:
                              - number
                              - 'null'
                          available:
                            type: boolean
                            enum:
                              - true
                          source_type:
                            type: string
                            enum:
                              - document
                          document_id:
                            type: string
                            format: uuid
                          document_name:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          page:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          section_title:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          context_before:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          context_after:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          original_quote:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                        required:
                          - source_ref
                          - citation_id
                          - title
                          - quote
                          - text
                          - verification
                          - verification_score
                          - available
                          - source_type
                          - document_id
                          - document_name
                          - page
                          - section_title
                          - context_before
                          - context_after
                          - original_quote
                      - type: object
                        properties:
                          source_ref:
                            type: integer
                            exclusiveMinimum: 0
                          citation_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          title:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          quote:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          text:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          verification:
                            type:
                              - string
                              - 'null'
                            enum:
                              - verified
                              - corrected
                              - recovered
                              - unverified
                              - null
                          verification_score:
                            type:
                              - number
                              - 'null'
                          available:
                            type: boolean
                            enum:
                              - true
                          source_type:
                            type: string
                            enum:
                              - web
                          url:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          cited_at:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                        required:
                          - source_ref
                          - citation_id
                          - title
                          - quote
                          - text
                          - verification
                          - verification_score
                          - available
                          - source_type
                          - url
                          - cited_at
                      - type: object
                        properties:
                          source_ref:
                            type: integer
                            exclusiveMinimum: 0
                          citation_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          title:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          quote:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          text:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          verification:
                            type:
                              - string
                              - 'null'
                            enum:
                              - verified
                              - corrected
                              - recovered
                              - unverified
                              - null
                          verification_score:
                            type:
                              - number
                              - 'null'
                          available:
                            type: boolean
                            enum:
                              - true
                          source_type:
                            type: string
                            enum:
                              - agreement_items
                          item_ids:
                            type: array
                            items:
                              type: string
                              format: uuid
                          agreement_item_refs:
                            type: array
                            items:
                              type: string
                              maxLength: 10000
                        required:
                          - source_ref
                          - citation_id
                          - title
                          - quote
                          - text
                          - verification
                          - verification_score
                          - available
                          - source_type
                          - item_ids
                          - agreement_item_refs
                      - type: object
                        properties:
                          source_ref:
                            type: integer
                            exclusiveMinimum: 0
                          citation_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          title:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          quote:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          text:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          verification:
                            type:
                              - string
                              - 'null'
                            enum:
                              - verified
                              - corrected
                              - recovered
                              - unverified
                              - null
                          verification_score:
                            type:
                              - number
                              - 'null'
                          available:
                            type: boolean
                            enum:
                              - true
                          source_type:
                            type: string
                            enum:
                              - user_context
                        required:
                          - source_ref
                          - citation_id
                          - title
                          - quote
                          - text
                          - verification
                          - verification_score
                          - available
                          - source_type
                      - type: object
                        properties:
                          source_ref:
                            type:
                              - integer
                              - 'null'
                            exclusiveMinimum: 0
                          citation_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          title:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          quote:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          text:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          verification:
                            type:
                              - string
                              - 'null'
                            enum:
                              - verified
                              - corrected
                              - recovered
                              - unverified
                              - null
                          verification_score:
                            type:
                              - number
                              - 'null'
                          source_type:
                            type:
                              - string
                              - 'null'
                          page:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          section_title:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          context_before:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          context_after:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          original_quote:
                            type:
                              - string
                              - 'null'
                            maxLength: 10000
                          available:
                            type: boolean
                            enum:
                              - false
                          reason:
                            type: string
                            enum:
                              - source_unavailable
                        required:
                          - source_ref
                          - citation_id
                          - title
                          - quote
                          - text
                          - verification
                          - verification_score
                          - source_type
                          - page
                          - section_title
                          - context_before
                          - context_after
                          - original_quote
                          - available
                          - reason
                truncated:
                  type: boolean
                  description: True when excerpts were cut at 10,000 characters.
              required:
                - citations
                - truncated
          required:
            - questions
            - price_item_ids
            - expected
            - invoiced
            - evidence
    Error_validation_error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - validation_error
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_invalid_token:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - invalid_token
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_forbidden_token_disabled_organization_required_insufficient_role_mfa_required:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - forbidden
                - token_disabled
                - organization_required
                - insufficient_role
                - mfa_required
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_not_found:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - not_found
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_conflict:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - conflict
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_rate_limit_exceeded:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - rate_limit_exceeded
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_internal_error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - internal_error
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    Error_service_unavailable:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - service_unavailable
            message:
              type: string
            request_id:
              type: string
            description:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                  field:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - field
                  - message
              maxItems: 20
            workflow_run_id:
              type: string
              format: uuid
            import_id:
              type: string
              format: uuid
            existing_party:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - supplier
                    - recipient
                id:
                  type: string
                  format: uuid
              required:
                - type
                - id
          required:
            - code
            - message
            - request_id
      required:
        - error
    AlertSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        title:
          type:
            - string
            - 'null'
        explanation:
          type:
            - string
            - 'null'
        verdict:
          type: string
          enum:
            - pending
            - accepted
            - dismissed
          description: >-
            The decision on the finding, independent of claim membership and
            credit.
        credit:
          type:
            - object
            - 'null'
          properties:
            at:
              type: string
              format: date-time
            source:
              type: string
              enum:
                - credit_note
                - user
            credit_note_id:
              type:
                - string
                - 'null'
              format: uuid
              description: >-
                Matched credit-note provenance, if available. Null for a user
                credit.
          required:
            - at
            - source
            - credit_note_id
          description: Supplier credit, independent of the verdict and claim.
        correction_type:
          type: string
          enum:
            - modify_item
            - modify_invoice
            - add_item
        confidence:
          type: object
          properties:
            level:
              type:
                - string
                - 'null'
              enum:
                - high
                - mid
                - low
                - null
            reason:
              type:
                - string
                - 'null'
          required:
            - level
            - reason
        impact_amount:
          type:
            - string
            - 'null'
          pattern: ^-?\d+(?:\.\d+)?$
        currency_code:
          type: string
        organization_currency:
          type: object
          properties:
            currency_code:
              type: string
              description: The organization's reporting currency from its settings.
            impact_amount:
              type:
                - string
                - 'null'
              pattern: ^-?\d+(?:\.\d+)?$
          required:
            - currency_code
            - impact_amount
          description: The impact converted with the rate stored on the alert.
        freshness:
          type: string
          enum:
            - current
            - outdated
            - unknown
        invalidation:
          type:
            - object
            - 'null'
          properties:
            at:
              type: string
              format: date-time
            reason:
              type: string
              enum:
                - unmatched
          required:
            - at
            - reason
          description: >-
            Set when the alert no longer counts, for example because its invoice
            no longer matches the agreement. It keeps its verdict, credit and
            claim, and counts again if the invoice matches again.
        invoice:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            invoice_number:
              type:
                - string
                - 'null'
            title:
              type:
                - string
                - 'null'
              description: The invoice's own title; its number is invoice_number.
            category:
              type: string
              enum:
                - invoice
                - credit_note
                - self_billed_invoice
            issued_date:
              type:
                - string
                - 'null'
              format: date
            due_date:
              type:
                - string
                - 'null'
              format: date
            currency_code:
              type:
                - string
                - 'null'
            total_amount_including_vat:
              type:
                - string
                - 'null'
              pattern: ^-?\d+(?:\.\d+)?$
          required:
            - id
            - invoice_number
            - title
            - category
            - issued_date
            - due_date
            - currency_code
            - total_amount_including_vat
        invoice_item:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            line_number:
              type: integer
            product_code:
              type:
                - string
                - 'null'
            description:
              type:
                - string
                - 'null'
            unit:
              type:
                - string
                - 'null'
          required:
            - id
            - line_number
            - product_code
            - description
            - unit
          readOnly: true
          description: The current invoice line. Null when no line is linked.
        agreement:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            title:
              type:
                - string
                - 'null'
            status:
              type: string
              enum:
                - draft
                - active
                - archived
            version:
              type: integer
              description: The current agreement version.
          required:
            - id
            - title
            - status
            - version
        supplier:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            title:
              type:
                - string
                - 'null'
          required:
            - id
            - title
        recipient:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            title:
              type:
                - string
                - 'null'
          required:
            - id
            - title
        topic:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            title:
              type:
                - string
                - 'null'
            is_locked:
              type: boolean
          required:
            - id
            - title
            - is_locked
        claim:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            title:
              type:
                - string
                - 'null'
            status:
              type: string
              enum:
                - pending
                - in_progress
                - completed
                - cancelled
          required:
            - id
            - title
            - status
          description: The claim this alert is currently attached to, if any.
        dismissal:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
              description: Alerts dismissed together with the same reason share this ID.
            category:
              type:
                - string
                - 'null'
              enum:
                - wrong_alert
                - valid_not_actioning
                - already_handled
                - duplicate_covered
                - other
                - null
            note:
              type:
                - string
                - 'null'
            dismissed_at:
              type: string
              format: date-time
            dismissed_by:
              type:
                - object
                - 'null'
              properties:
                user:
                  type: object
                  properties:
                    id:
                      type: string
                    name:
                      type:
                        - string
                        - 'null'
                    deleted:
                      type: boolean
                      description: >-
                        The account was deleted. The name is kept, or null once
                        the account is anonymised.
                  required:
                    - id
                    - name
                    - deleted
                api_key:
                  type:
                    - object
                    - 'null'
                  properties:
                    id:
                      type: string
                      format: uuid
                    name:
                      type: string
                  required:
                    - id
                    - name
                  description: The API key used, retained after revocation.
              required:
                - user
                - api_key
              description: >-
                The person, and API key if one was used. Null when no person is
                recorded.
          required:
            - id
            - category
            - note
            - dismissed_at
            - dismissed_by
          description: >-
            Why the alert was dismissed, while its verdict is dismissed,
            credited or not. Dismiss it again with a different category or note
            to change the reason. Reopening or accepting clears it; the alert
            activity keeps the history.
        provenance:
          type: object
          properties:
            origin:
              type: string
              enum:
                - check
                - user
                - api_key
              description: >-
                Who created the alert: a compliance check, a person, or a person
                through an API key. Re-checks and check resets never remove
                alerts created by people or API keys.
            created_by:
              type:
                - object
                - 'null'
              properties:
                user:
                  type: object
                  properties:
                    id:
                      type: string
                    name:
                      type:
                        - string
                        - 'null'
                    deleted:
                      type: boolean
                      description: >-
                        The account was deleted. The name is kept, or null once
                        the account is anonymised.
                  required:
                    - id
                    - name
                    - deleted
                api_key:
                  type:
                    - object
                    - 'null'
                  properties:
                    id:
                      type: string
                      format: uuid
                    name:
                      type: string
                  required:
                    - id
                    - name
                  description: The API key used, retained after revocation.
              required:
                - user
                - api_key
              description: >-
                The person, and API key if one was used. Null for alerts from
                checks.
            agreement_version:
              type:
                - integer
                - 'null'
              description: The agreement version assessed; compare with agreement.version.
            invoice_fingerprint:
              type:
                - string
                - 'null'
            retained_check:
              type:
                - object
                - 'null'
              properties:
                id:
                  type: string
                  format: uuid
              required:
                - id
              description: >-
                The compliance check that produced this alert. Null for older
                alerts.
          required:
            - origin
            - created_by
            - agreement_version
            - invoice_fingerprint
            - retained_check
        correction_relationships:
          type: array
          items:
            type: object
            properties:
              replacement_alert_id:
                type: string
                format: uuid
              replaced_alert_id:
                type: string
                format: uuid
            required:
              - replacement_alert_id
              - replaced_alert_id
          maxItems: 100
          description: Links between an added-item alert and the line alerts it replaces.
        correction_relationships_truncated:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - title
        - explanation
        - verdict
        - credit
        - correction_type
        - confidence
        - impact_amount
        - currency_code
        - organization_currency
        - freshness
        - invalidation
        - invoice
        - invoice_item
        - agreement
        - supplier
        - recipient
        - topic
        - claim
        - dismissal
        - provenance
        - correction_relationships
        - correction_relationships_truncated
        - created_at
        - updated_at
  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).

````