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

# Export selected invoices as CSV

> Streams the complete selection using the same filters as list/metrics. Summary rows traverse invoice UUID ascending; line rows traverse invoice UUID, line number and line UUID. Does not accept list cursors or sorting. Live traversal reapplies filters and team definitions per batch: concurrent changes may move records into or out of later batches, and the export is not a snapshot. Invoice-items emits one row per stored line (invoices without lines contribute no rows). Exact decimals, blank nulls, JSON arrays, UTF-8 BOM, CRLF and formula-safe text. Empty selections contain the header. Failures after streaming starts terminate the download; retry starts a fresh export. No saved file or byte-range resume. Use parseAs: stream with the generated client.



## OpenAPI

````yaml /openapi-preview.json get /v1/invoices/export
openapi: 3.1.0
info:
  title: Watchdog API (preview)
  version: 1.0.0
  description: >-
    Development preview for agreements, price items, document relationships,
    canonical invoices, alerts and alert topics, claims and attached alerts,
    shared entity activity and comments, Document uploads, invoice imports,
    explicit invoice-agreement matching, and workflow runs. This contract is
    under development and is not served by api.watchdog.no. Request bodies are
    limited to 2 MiB (2,097,152 bytes), including all JSON fields and line data,
    except POST /v1/support/contact which permits 32 MiB for base64 attachments.
    File bytes are uploaded directly to storage. The existing public REST
    service retains its separate contract.
servers:
  - url: http://localhost:3500
    description: Local development Worker
security: []
paths:
  /v1/invoices/export:
    get:
      tags:
        - Invoices
      summary: Export selected invoices as CSV
      description: >-
        Streams the complete selection using the same filters as list/metrics.
        Summary rows traverse invoice UUID ascending; line rows traverse invoice
        UUID, line number and line UUID. Does not accept list cursors or
        sorting. Live traversal reapplies filters and team definitions per
        batch: concurrent changes may move records into or out of later batches,
        and the export is not a snapshot. Invoice-items emits one row per stored
        line (invoices without lines contribute no rows). Exact decimals, blank
        nulls, JSON arrays, UTF-8 BOM, CRLF and formula-safe text. Empty
        selections contain the header. Failures after streaming starts terminate
        the download; retry starts a fresh export. No saved file or byte-range
        resume. Use parseAs: stream with the generated client.
      operationId: exportInvoices
      parameters:
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
          description: >-
            Required for personal API keys. Target one organization you have
            access to. Migrated keys may omit it to use their original
            organization. For Clerk sessions, it must match the active
            organization.
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              Match the shared teams the authenticated user belongs to in this
              organization. Teams combine with OR; other filters combine with
              AND. No memberships or saved rules means no matches. Cannot be
              combined with team_ids when true.
          required: false
          description: >-
            Match the shared teams the authenticated user belongs to in this
            organization. Teams combine with OR; other filters combine with AND.
            No memberships or saved rules means no matches. Cannot be combined
            with team_ids when true.
          name: mine
          in: query
        - schema:
            type: string
            description: >-
              Shared team IDs (maximum 50; comma-separated in a query string, a
              JSON array in a command body). Teams combine with OR. Missing,
              foreign, or personal teams return 404; invalid saved rules return
              409.
          required: false
          description: >-
            Shared team IDs (maximum 50; comma-separated in a query string, a
            JSON array in a command body). Teams combine with OR. Missing,
            foreign, or personal teams return 404; invalid saved rules return
            409.
          name: team_ids
          in: query
        - schema:
            type: string
            minLength: 1
            maxLength: 200
            description: Case-insensitive substring match on invoice number or title.
          required: false
          description: Case-insensitive substring match on invoice number or title.
          name: search
          in: query
        - schema:
            type: string
            description: >-
              Match any canonical supplier UUID or literal null for no supplier.
              Maximum 50 comma-separated values; omit for all suppliers. Empty
              entries are invalid.
          required: false
          description: >-
            Match any canonical supplier UUID or literal null for no supplier.
            Maximum 50 comma-separated values; omit for all suppliers. Empty
            entries are invalid.
          name: supplier_ids
          in: query
        - schema:
            type: string
            description: >-
              Match any canonical recipient UUID or literal null for no
              recipient. Maximum 50 comma-separated values; omit for all
              recipients. Empty entries are invalid.
          required: false
          description: >-
            Match any canonical recipient UUID or literal null for no recipient.
            Maximum 50 comma-separated values; omit for all recipients. Empty
            entries are invalid.
          name: recipient_ids
          in: query
        - schema:
            type: string
            description: >-
              Match any listed category: invoice, credit_note,
              self_billed_invoice. Maximum 50 comma-separated values; omit for
              all categories.
          required: false
          description: >-
            Match any listed category: invoice, credit_note,
            self_billed_invoice. Maximum 50 comma-separated values; omit for all
            categories.
          name: categories
          in: query
        - schema:
            type: string
            description: >-
              Match any three-letter currency code (case-insensitive), or
              literal null for unknown currency. Maximum 50 comma-separated
              values; omit for all currencies. Example: NOK,EUR,null.
          required: false
          description: >-
            Match any three-letter currency code (case-insensitive), or literal
            null for unknown currency. Maximum 50 comma-separated values; omit
            for all currencies. Example: NOK,EUR,null.
          name: currency_codes
          in: query
        - schema:
            type: string
            enum:
              - and
              - or
            default: and
            description: >-
              and requires every supplied column filter; or requires at least
              one. Both bounds within each date range must match, and that range
              is one group member. Organization, published/deleted state,
              search, agreement_ids and mine/team scope are always required
              outside the group. No column filters means no group restriction.
          required: false
          description: >-
            and requires every supplied column filter; or requires at least one.
            Both bounds within each date range must match, and that range is one
            group member. Organization, published/deleted state, search,
            agreement_ids and mine/team scope are always required outside the
            group. No column filters means no group restriction.
          name: join_operator
          in: query
        - schema:
            type: string
            enum:
              - is
              - is_not
            default: is
            description: >-
              Apply to supplier_ids: is matches any selected value; is_not
              excludes all selected values. Omitted selections add no
              restriction. is_not requires a selection. For nullable fields,
              exclusion includes null unless null is explicitly excluded.
          required: false
          description: >-
            Apply to supplier_ids: is matches any selected value; is_not
            excludes all selected values. Omitted selections add no restriction.
            is_not requires a selection. For nullable fields, exclusion includes
            null unless null is explicitly excluded.
          name: supplier_operator
          in: query
        - schema:
            type: string
            enum:
              - is
              - is_not
            default: is
            description: >-
              Apply to recipient_ids: is matches any selected value; is_not
              excludes all selected values. Omitted selections add no
              restriction. is_not requires a selection. For nullable fields,
              exclusion includes null unless null is explicitly excluded.
          required: false
          description: >-
            Apply to recipient_ids: is matches any selected value; is_not
            excludes all selected values. Omitted selections add no restriction.
            is_not requires a selection. For nullable fields, exclusion includes
            null unless null is explicitly excluded.
          name: recipient_operator
          in: query
        - schema:
            type: string
            enum:
              - is
              - is_not
            default: is
            description: >-
              Apply to categories: is matches any selected value; is_not
              excludes all selected values. Omitted selections add no
              restriction. is_not requires a selection. For nullable fields,
              exclusion includes null unless null is explicitly excluded.
          required: false
          description: >-
            Apply to categories: is matches any selected value; is_not excludes
            all selected values. Omitted selections add no restriction. is_not
            requires a selection. For nullable fields, exclusion includes null
            unless null is explicitly excluded.
          name: category_operator
          in: query
        - schema:
            type: string
            enum:
              - is
              - is_not
            default: is
            description: >-
              Apply to currency_codes: is matches any selected value; is_not
              excludes all selected values. Omitted selections add no
              restriction. is_not requires a selection. For nullable fields,
              exclusion includes null unless null is explicitly excluded.
          required: false
          description: >-
            Apply to currency_codes: is matches any selected value; is_not
            excludes all selected values. Omitted selections add no restriction.
            is_not requires a selection. For nullable fields, exclusion includes
            null unless null is explicitly excluded.
          name: currency_operator
          in: query
        - schema:
            type: string
            enum:
              - is
              - is_not
            default: is
            description: >-
              Apply to confidence_levels: is matches any selected value; is_not
              excludes all selected values. Omitted selections add no
              restriction. is_not requires a selection. For nullable fields,
              exclusion includes null unless null is explicitly excluded.
          required: false
          description: >-
            Apply to confidence_levels: is matches any selected value; is_not
            excludes all selected values. Omitted selections add no restriction.
            is_not requires a selection. For nullable fields, exclusion includes
            null unless null is explicitly excluded.
          name: confidence_operator
          in: query
        - schema:
            type: string
            enum:
              - is
              - is_not
            default: is
            description: >-
              Apply to check_statuses: is matches any selected value; is_not
              excludes all selected values. Omitted selections add no
              restriction. is_not requires a selection. For nullable fields,
              exclusion includes null unless null is explicitly excluded.
          required: false
          description: >-
            Apply to check_statuses: is matches any selected value; is_not
            excludes all selected values. Omitted selections add no restriction.
            is_not requires a selection. For nullable fields, exclusion includes
            null unless null is explicitly excluded.
          name: check_status_operator
          in: query
        - schema:
            type: string
            enum:
              - is
              - is_not
            default: is
            description: >-
              Apply to alert_statuses: is matches any selected value; is_not
              excludes all selected values. Omitted selections add no
              restriction. is_not requires a selection. For nullable fields,
              exclusion includes null unless null is explicitly excluded.
          required: false
          description: >-
            Apply to alert_statuses: is matches any selected value; is_not
            excludes all selected values. Omitted selections add no restriction.
            is_not requires a selection. For nullable fields, exclusion includes
            null unless null is explicitly excluded.
          name: alert_status_operator
          in: query
        - schema:
            type: string
            description: >-
              Combined alert status, in precedence order: credited (fully
              financially covered by credit notes), checking (active checks),
              has_issues (pending or claimed alerts), clean (completed coverage
              without open alerts), not_checked (all remaining coverage). Uses
              alert_scope. Comma-separated, maximum 50; omit for all states.
          required: false
          description: >-
            Combined alert status, in precedence order: credited (fully
            financially covered by credit notes), checking (active checks),
            has_issues (pending or claimed alerts), clean (completed coverage
            without open alerts), not_checked (all remaining coverage). Uses
            alert_scope. Comma-separated, maximum 50; omit for all states.
          name: alert_statuses
          in: query
        - schema:
            type: string
            description: >-
              Original extraction confidence: high, mid, low or unknown. Both
              successful creating-import stages must retain confidence
              assessments and stage fingerprints; publication validates their
              respective cache keys. The lower level wins. Structured/XML
              creation and unavailable history are unknown. Comma-separated,
              maximum 50; omit for all levels.
          required: false
          description: >-
            Original extraction confidence: high, mid, low or unknown. Both
            successful creating-import stages must retain confidence assessments
            and stage fingerprints; publication validates their respective cache
            keys. The lower level wins. Structured/XML creation and unavailable
            history are unknown. Comma-separated, maximum 50; omit for all
            levels.
          name: confidence_levels
          in: query
        - schema:
            type: string
            description: >-
              Canonical check coverage in alert_scope: not_checkable (credit
              note or recorded credit-note match), checking (active work),
              not_checked (no check recorded), completed (all current matches
              checked), incomplete (missing, failed, cancelled, outdated or
              unknown coverage). Comma-separated, maximum 50; omit for all
              states.
          required: false
          description: >-
            Canonical check coverage in alert_scope: not_checkable (credit note
            or recorded credit-note match), checking (active work), not_checked
            (no check recorded), completed (all current matches checked),
            incomplete (missing, failed, cancelled, outdated or unknown
            coverage). Comma-separated, maximum 50; omit for all states.
          name: check_statuses
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              true requires at least one recorded credit-note relationship;
              false selects zero. For invoice/self_billed_invoice this means
              linked credit notes; for credit_note this means matched invoices.
              Includes retained links to soft-deleted counterparts. Does not
              establish financial resolution. Omit for either.
          required: false
          description: >-
            true requires at least one recorded credit-note relationship; false
            selects zero. For invoice/self_billed_invoice this means linked
            credit notes; for credit_note this means matched invoices. Includes
            retained links to soft-deleted counterparts. Does not establish
            financial resolution. Omit for either.
          name: has_recorded_match
          in: query
        - schema:
            type: string
            enum:
              - invoice
              - selected_agreements
            default: invoice
            description: >-
              Selected scope requires agreement_ids and evaluates only currently
              matched selected agreements. Applies to checks, alert counts,
              filters and metrics.
          required: false
          description: >-
            Selected scope requires agreement_ids and evaluates only currently
            matched selected agreements. Applies to checks, alert counts,
            filters and metrics.
          name: alert_scope
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
            description: >-
              Earliest issue date (YYYY-MM-DD), inclusive. Unknown dates do not
              match this range. Omit for no bound.
          required: false
          description: >-
            Earliest issue date (YYYY-MM-DD), inclusive. Unknown dates do not
            match this range. Omit for no bound.
          name: issued_from
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
            description: >-
              Latest issue date (YYYY-MM-DD), inclusive. Unknown dates do not
              match this range. Omit for no bound.
          required: false
          description: >-
            Latest issue date (YYYY-MM-DD), inclusive. Unknown dates do not
            match this range. Omit for no bound.
          name: issued_through
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
            description: >-
              Earliest due date (YYYY-MM-DD), inclusive. Unknown dates do not
              match this range. Omit for no bound.
          required: false
          description: >-
            Earliest due date (YYYY-MM-DD), inclusive. Unknown dates do not
            match this range. Omit for no bound.
          name: due_from
          in: query
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
            description: >-
              Latest due date (YYYY-MM-DD), inclusive. Unknown dates do not
              match this range. Omit for no bound.
          required: false
          description: >-
            Latest due date (YYYY-MM-DD), inclusive. Unknown dates do not match
            this range. Omit for no bound.
          name: due_through
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              Filter by deterministic financial validation, independent of
              extraction confidence or human approval.
          required: false
          description: >-
            Filter by deterministic financial validation, independent of
            extraction confidence or human approval.
          name: financially_valid
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              Filter by explicit human extraction confirmation. Does not change
              confidence or financial validity.
          required: false
          description: >-
            Filter by explicit human extraction confirmation. Does not change
            confidence or financial validity.
          name: extraction_confirmed
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              true selects unconfirmed low/mid extraction confidence, unmatched
              credit notes, or financially invalid invoices. false selects the
              exact complement. Always combines with the other selection using
              AND. Unknown confidence alone does not recommend review.
          required: false
          description: >-
            true selects unconfirmed low/mid extraction confidence, unmatched
            credit notes, or financially invalid invoices. false selects the
            exact complement. Always combines with the other selection using
            AND. Unknown confidence alone does not recommend review.
          name: review_recommended
          in: query
        - schema:
            type: string
            description: >-
              Comma-separated agreement IDs (maximum 50). Select invoices
              matched to any listed agreement in the target organization,
              regardless of agreement status. Unknown, deleted, or foreign
              agreements contribute no matches. Combines with other filters
              using AND; invoices are returned and counted once even if matched
              to several selected agreements.
          required: false
          description: >-
            Comma-separated agreement IDs (maximum 50). Select invoices matched
            to any listed agreement in the target organization, regardless of
            agreement status. Unknown, deleted, or foreign agreements contribute
            no matches. Combines with other filters using AND; invoices are
            returned and counted once even if matched to several selected
            agreements.
          name: agreement_ids
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              true requires at least one current organization-owned, nondeleted
              agreement match; false requires none. Omit for either. Independent
              of credit-note matching and completed checks.
          required: false
          description: >-
            true requires at least one current organization-owned, nondeleted
            agreement match; false requires none. Omit for either. Independent
            of credit-note matching and completed checks.
          name: has_agreement_match
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              true is equivalent to check_statuses=completed in alert_scope;
              false includes every other state. Omit for either.
          required: false
          description: >-
            true is equivalent to check_statuses=completed in alert_scope; false
            includes every other state. Omit for either.
          name: alert_checked
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              true excludes credit notes and invoices with recorded credit-note
              matches; false selects those excluded resources. Eligibility is
              invoice-wide even in selected-agreement scope. Omit for either.
          required: false
          description: >-
            true excludes credit notes and invoices with recorded credit-note
            matches; false selects those excluded resources. Eligibility is
            invoice-wide even in selected-agreement scope. Omit for either.
          name: alert_checkable
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              true requires retained pending or claimed alerts in alert_scope
              (including outdated findings); false requires none. No open alerts
              does not prove completed checks. Omit for either.
          required: false
          description: >-
            true requires retained pending or claimed alerts in alert_scope
            (including outdated findings); false requires none. No open alerts
            does not prove completed checks. Omit for either.
          name: has_open_alerts
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            default: 'false'
            description: >-
              false selects active invoices; true selects only soft-deleted
              invoices.
          required: false
          description: >-
            false selects active invoices; true selects only soft-deleted
            invoices.
          name: deleted
          in: query
        - schema:
            type: string
            enum:
              - invoice
              - invoice-items
            default: invoice
            description: >-
              invoice emits one row per selected invoice; invoice-items emits
              one row per stored line with invoice columns repeated. Invoices
              without lines contribute no invoice-items rows.
          required: false
          description: >-
            invoice emits one row per selected invoice; invoice-items emits one
            row per stored line with invoice columns repeated. Invoices without
            lines contribute no invoice-items rows.
          name: granularity
          in: query
      responses:
        '200':
          description: >-
            Streaming CSV download. Success requires reading the entire body;
            HTTP 200 alone does not establish completion.
          headers:
            Content-Disposition:
              schema:
                type: string
              required: true
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
              required: true
          content:
            text/csv:
              schema:
                type: string
                format: binary
        '400':
          description: >-
            Invalid request format, parameters, or body. Details contain up to
            20 actionable field errors; the complete encoded request body must
            be at most 2 MiB (2,097,152 bytes).
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request identifier for support and diagnostics; also included in
                error bodies.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
              required: false
              description: >-
                Organization-scoped API responses must not be cached. May be
                absent for requests rejected before routing.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '120'
              required: false
              description: >-
                Requests per minute for the applicable limiter, when evaluated.
                Authenticated requests use the credential limit; an IP rejection
                uses the IP limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error_validation_error'
              example:
                error:
                  code: validation_error
                  message: >-
                    Invalid request format, parameters, or body. Details contain
                    up to 20 actionable field errors; the complete encoded
                    request body must be at most 2 MiB (2,097,152 bytes).
                  request_id: req_example
        '401':
          description: Missing or invalid bearer credential.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request identifier for support and diagnostics; also included in
                error bodies.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
              required: false
              description: >-
                Organization-scoped API responses must not be cached. May be
                absent for requests rejected before routing.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '120'
              required: false
              description: >-
                Requests per minute for the applicable limiter, when evaluated.
                Authenticated requests use the credential limit; an IP rejection
                uses the IP limit.
            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: Missing or invalid bearer credential.
                  request_id: req_example
        '403':
          description: >-
            Access denied: forbidden, token_disabled, organization_required,
            insufficient_role, or mfa_required. Check the error code and
            effective permissions.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request identifier for support and diagnostics; also included in
                error bodies.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
              required: false
              description: >-
                Organization-scoped API responses must not be cached. May be
                absent for requests rejected before routing.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '120'
              required: false
              description: >-
                Requests per minute for the applicable limiter, when evaluated.
                Authenticated requests use the credential limit; an IP rejection
                uses the IP limit.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Error_forbidden_token_disabled_organization_required_insufficient_role_mfa_required
              example:
                error:
                  code: forbidden
                  message: >-
                    Access denied: forbidden, token_disabled,
                    organization_required, insufficient_role, or mfa_required.
                    Check the error code and effective permissions.
                  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 identifier for support and diagnostics; also included in
                error bodies.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
              required: false
              description: >-
                Organization-scoped API responses must not be cached. May be
                absent for requests rejected before routing.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '120'
              required: false
              description: >-
                Requests per minute for the applicable limiter, when evaluated.
                Authenticated requests use the credential limit; an IP rejection
                uses the IP limit.
          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: >-
            One or more selected teams have invalid saved filter rules. Update
            the team filters before retrying.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request identifier for support and diagnostics; also included in
                error bodies.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
              required: false
              description: >-
                Organization-scoped API responses must not be cached. May be
                absent for requests rejected before routing.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '120'
              required: false
              description: >-
                Requests per minute for the applicable limiter, when evaluated.
                Authenticated requests use the credential limit; an IP rejection
                uses the IP limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error_conflict'
              example:
                error:
                  code: conflict
                  message: >-
                    One or more selected teams have invalid saved filter rules.
                    Update the team filters before retrying.
                  request_id: req_example
        '429':
          description: The IP or authenticated credential exceeded its request limit.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request identifier for support and diagnostics; also included in
                error bodies.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
              required: false
              description: >-
                Organization-scoped API responses must not be cached. May be
                absent for requests rejected before routing.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '120'
              required: false
              description: >-
                Requests per minute for the applicable limiter, when evaluated.
                Authenticated requests use the credential limit; an IP rejection
                uses the IP limit.
            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: >-
                    The IP or authenticated credential exceeded its request
                    limit.
                  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 identifier for support and diagnostics; also included in
                error bodies.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
              required: false
              description: >-
                Organization-scoped API responses must not be cached. May be
                absent for requests rejected before routing.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '120'
              required: false
              description: >-
                Requests per minute for the applicable limiter, when evaluated.
                Authenticated requests use the credential limit; an IP rejection
                uses the IP limit.
          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: >-
            Authentication infrastructure is unavailable or rate limited. Honor
            Retry-After when provided.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request identifier for support and diagnostics; also included in
                error bodies.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
              required: false
              description: >-
                Organization-scoped API responses must not be cached. May be
                absent for requests rejected before routing.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '120'
              required: false
              description: >-
                Requests per minute for the applicable limiter, when evaluated.
                Authenticated requests use the credential limit; an IP rejection
                uses the IP limit.
            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: >-
                    Authentication infrastructure is unavailable or rate
                    limited. Honor Retry-After when provided.
                  request_id: req_example
      security:
        - ApiKeyBearer: []
        - ClerkSessionBearer: []
components:
  schemas:
    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
  securitySchemes:
    ApiKeyBearer:
      type: http
      scheme: bearer
      description: >-
        Personal API key. Send X-Organization-Id. The required cumulative level
        is listed in x-watchdog-permission.
    ClerkSessionBearer:
      type: http
      scheme: bearer
      description: Clerk session with an active organization.

````