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

# Update a purchase order

> Send only the fields to change; null clears a field. Changes to a draft, and to an opened order's title, owner, internal note, invoice approvers, status, archiving and agreement, need no revision: the last save wins. Changing an opened order's terms (the note to the supplier among them) or lines needs expected_revision and records a new revision. The supplier, buyer, currency and commitment basis are terms; on an order pushed to an ERP, or while a push is queued or running, changing them returns 409 (pushed), and a new supplier unlinks an agreement that names other suppliers unless agreement_id is sent too. On an opened order, a term change that an approval rule for orders matches and that raises the commitment or changes the supplier (a new currency or commitment basis counts as a raise) becomes the order's proposed_revision and asks for approval, while the rest of the request applies; until it is decided, changing the terms returns 409 (proposal_waiting), and closing or cancelling the order withdraws it. The resulting order is validated as a whole: a request that would leave it invalid returns 400 and changes nothing. Edits start no invoice matching: refreshPurchaseOrderInvoices reconciles the order's invoices on request, and a linked invoice whose supplier or buyer differs from the order's reads parties_differ.



## OpenAPI

````yaml /openapi.json patch /v1/purchase-orders/{id}
openapi: 3.1.0
info:
  title: Watchdog API
  version: 1.0.0
  description: >-
    The Watchdog API is served from https://api.watchdog.no. Request bodies are
    limited to 2 MiB unless an endpoint says otherwise. Files are uploaded
    directly to storage, not through the API.
servers:
  - url: https://api.watchdog.no
    description: Watchdog API
security: []
paths:
  /v1/purchase-orders/{id}:
    patch:
      tags:
        - Purchase orders
      summary: Update a purchase order
      description: >-
        Send only the fields to change; null clears a field. Changes to a draft,
        and to an opened order's title, owner, internal note, invoice approvers,
        status, archiving and agreement, need no revision: the last save wins.
        Changing an opened order's terms (the note to the supplier among them)
        or lines needs expected_revision and records a new revision. The
        supplier, buyer, currency and commitment basis are terms; on an order
        pushed to an ERP, or while a push is queued or running, changing them
        returns 409 (pushed), and a new supplier unlinks an agreement that names
        other suppliers unless agreement_id is sent too. On an opened order, a
        term change that an approval rule for orders matches and that raises the
        commitment or changes the supplier (a new currency or commitment basis
        counts as a raise) becomes the order's proposed_revision and asks for
        approval, while the rest of the request applies; until it is decided,
        changing the terms returns 409 (proposal_waiting), and closing or
        cancelling the order withdraws it. The resulting order is validated as a
        whole: a request that would leave it invalid returns 400 and changes
        nothing. Edits start no invoice matching: refreshPurchaseOrderInvoices
        reconciles the order's invoices on request, and a linked invoice whose
        supplier or buyer differs from the order's reads parties_differ.
      operationId: updatePurchaseOrder
      parameters:
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
          description: >-
            The organization to act in. Required for personal API keys; list the
            organizations you can access with GET /v1/organizations.
        - schema:
            type: string
            format: uuid
          required: true
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            example:
              expected_revision: 1
              line_item_changes:
                update:
                  - id: 0e4b1f62-5a8c-4d3e-9b1a-2f6c8d7e9a10
                    unit_price: '12500'
            schema:
              type: object
              properties:
                title:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
                supplier_id:
                  type:
                    - string
                    - 'null'
                  format: uuid
                company_id:
                  type: string
                  format: uuid
                  description: >-
                    The workspace company that places the order (listCompanies).
                    Its own recipient becomes the order's buyer, created from
                    the company's name and registration number when it has none.
                    On PATCH, only while a draft: a new company clears the
                    order's and its lines' coding, which belong to the old
                    company's chart.
                buyer_id:
                  type:
                    - string
                    - 'null'
                  format: uuid
                  description: >-
                    The recipient that placed the order (Peppol buyer). Send
                    company_id instead unless the order names another of the
                    company's recipients.
                owner_user_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                  maxLength: 200
                  pattern: ^[A-Za-z0-9_-]+$
                agreement_id:
                  type:
                    - string
                    - 'null'
                  format: uuid
                commitment_basis:
                  type: string
                  enum:
                    - lines
                    - amount_limit
                currency_code:
                  type:
                    - string
                    - 'null'
                  pattern: ^[A-Z]{3}$
                amount_limit:
                  type:
                    - string
                    - 'null'
                  maxLength: 100
                  pattern: ^-?\d+(?:\.\d+)?$
                unordered_charges:
                  type: string
                  enum:
                    - flag
                    - accept
                  description: >-
                    Invoice lines the order's lines don't cover, like freight:
                    flag (default) or accept.
                unordered_charges_limit:
                  type:
                    - string
                    - 'null'
                  maxLength: 100
                  pattern: ^-?\d+(?:\.\d+)?$
                  description: >-
                    Only with accept: the most accepted across the order's
                    invoices, excl. VAT; null for all.
                scope_description:
                  type:
                    - string
                    - 'null'
                  maxLength: 5000
                budget:
                  type:
                    - string
                    - 'null'
                  maxLength: 100
                  pattern: ^-?\d+(?:\.\d+)?$
                  description: >-
                    Internal, excluding VAT: what you expect to spend, such as
                    before the supplier prices the job. Not a term: never
                    printed, sent or pushed.
                issued_date:
                  type:
                    - string
                    - 'null'
                  pattern: ^\d{4}-\d{2}-\d{2}$
                valid_from:
                  type:
                    - string
                    - 'null'
                  pattern: ^\d{4}-\d{2}-\d{2}$
                valid_until:
                  type:
                    - string
                    - 'null'
                  pattern: ^\d{4}-\d{2}-\d{2}$
                delivery_date:
                  type:
                    - string
                    - 'null'
                  pattern: ^\d{4}-\d{2}-\d{2}$
                delivery:
                  type:
                    - object
                    - 'null'
                  properties:
                    name:
                      type:
                        - string
                        - 'null'
                      maxLength: 500
                      default: null
                    address:
                      type: object
                      properties:
                        street:
                          type:
                            - string
                            - 'null'
                          maxLength: 500
                          default: null
                        postal_code:
                          type:
                            - string
                            - 'null'
                          maxLength: 50
                          default: null
                        city:
                          type:
                            - string
                            - 'null'
                          maxLength: 200
                          default: null
                        country_code:
                          type:
                            - string
                            - 'null'
                          pattern: ^(?:[A-Z]{2})?$
                          default: null
                      additionalProperties: false
                  required:
                    - address
                  additionalProperties: false
                  description: >-
                    Where to deliver: Peppol Delivery/DeliveryParty name and
                    DeliveryLocation/Address. Null delivers to the buyer's own
                    address. PATCH replaces the whole destination. Left out on
                    create, the order takes its company's default delivery
                    address (listDeliveryAddresses), else the buyer's.
                buyer_reference:
                  type:
                    - string
                    - 'null'
                  maxLength: 200
                sales_order_reference:
                  type:
                    - string
                    - 'null'
                  maxLength: 200
                contract_reference:
                  type:
                    - string
                    - 'null'
                  maxLength: 200
                project_reference:
                  type:
                    - string
                    - 'null'
                  maxLength: 200
                dimension_value_ids:
                  type: array
                  items:
                    type: string
                    format: uuid
                  maxItems: 50
                  description: >-
                    Where the order's cost is booked: dimension values of its
                    company (listDimensionValues), at most one per dimension;
                    the buyer gives the company. Each line takes them, except
                    where it holds its own value for that dimension, and
                    invoices billing the order take them as coding suggestions.
                    Not a term: changing it records no revision. Replaced whole;
                    [] removes them.
                note_to_supplier:
                  type:
                    - string
                    - 'null'
                  maxLength: 5000
                  description: >-
                    Free text for the supplier, printed on the order (Peppol
                    Order Note). Not internal_note, which the supplier never
                    sees.
                internal_note:
                  type:
                    - string
                    - 'null'
                  maxLength: 5000
                line_item_changes:
                  type: object
                  properties:
                    create:
                      type: array
                      items:
                        $ref: '#/components/schemas/PurchaseOrderLineCreate'
                      maxItems: 1000
                      default: []
                    update:
                      type: array
                      items:
                        $ref: '#/components/schemas/PurchaseOrderLineUpdate'
                      maxItems: 1000
                      default: []
                    remove:
                      type: array
                      items:
                        type: string
                        format: uuid
                      maxItems: 1000
                      default: []
                  additionalProperties: false
                  description: >-
                    An update changes only the fields you send, including each
                    field of item. A removed line is deleted from a draft and
                    cancelled on an opened order.
                invoice_approvers:
                  $ref: '#/components/schemas/PurchaseOrderInvoiceApproversInput'
                delivery_address_id:
                  type: string
                  format: uuid
                  description: >-
                    One of the company's delivery addresses
                    (listDeliveryAddresses), copied into the order's delivery.
                    Not stored: the order keeps its copy when the address
                    changes. Send it instead of delivery.
                status:
                  type: string
                  enum:
                    - draft
                    - open
                    - closed
                    - cancelled
                  description: >-
                    open opens a draft as revision 1, or reopens a closed order.
                    A draft that an approval rule for orders matches
                    (approval_required), or that has approvers picked
                    (updatePurchaseOrderApprovers), asks them and the rules'
                    approvers instead, and stays an editable draft until one
                    approves it. closed and cancelled take status_reason;
                    cancelled is final. Waiting for approval is not a status.
                status_reason:
                  type:
                    - string
                    - 'null'
                  maxLength: 2000
                archived:
                  type: boolean
                  description: Only an order that is not open can be archived.
                expected_revision:
                  type: integer
                  exclusiveMinimum: 0
                  maximum: 2147483647
                  description: >-
                    The revision you edited, needed to change an opened order's
                    terms or lines: missing returns 400, outdated 409.
                approval:
                  $ref: '#/components/schemas/PurchaseOrderApprovalDecision'
                proposed_revision:
                  $ref: '#/components/schemas/PurchaseOrderProposalDecision'
                agreement_findings:
                  type: array
                  items:
                    type: object
                    properties:
                      target:
                        type: string
                        minLength: 1
                        maxLength: 200
                      fingerprint:
                        type: string
                        pattern: ^[0-9a-f]{64}$
                    required:
                      - target
                      - fingerprint
                    additionalProperties: false
                  minItems: 1
                  maxItems: 1000
                  description: >-
                    unit_price findings of getPurchaseOrderAgreementCheck to fix
                    with the agreement's price, as the check returned them. Sent
                    on its own, with at most title, owner_user_id, internal_note
                    and expected_revision; a finding that changed since it was
                    read returns 409.
                rejected_agreement_ids:
                  type: array
                  items:
                    type: string
                    format: uuid
                  maxItems: 100
                  description: >-
                    Every agreement dismissed as a suggestion for the order;
                    leaving one out restores it. Unlinking an automatically
                    linked agreement dismisses it without matching again; a link
                    is never replaced automatically.
              additionalProperties: false
      responses:
        '200':
          description: The purchase order.
          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/PurchaseOrder'
        '400':
          description: >-
            The request is invalid. details lists up to 20 field errors. Request
            bodies are limited to 2 MiB.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: validation_error
                  message: >-
                    The request is invalid. details lists up to 20 field errors.
                    Request bodies are limited to 2 MiB.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_validation_error'
        '401':
          description: The bearer token is missing or invalid.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
            WWW-Authenticate:
              schema:
                type: string
              required: false
              description: Bearer authentication challenge, when supplied.
          content:
            application/json:
              example:
                error:
                  code: invalid_token
                  message: The bearer token is missing or invalid.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_invalid_token'
        '403':
          description: >-
            Access denied. The error code says why: forbidden, token_disabled,
            organization_required, insufficient_role or mfa_required.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: forbidden
                  message: >-
                    Access denied. The error code says why: forbidden,
                    token_disabled, organization_required, insufficient_role or
                    mfa_required.
                  request_id: req_example
              schema:
                $ref: >-
                  #/components/schemas/Error_forbidden_token_disabled_organization_required_insufficient_role_mfa_required
        '404':
          description: The resource does not exist in the current organization.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: not_found
                  message: The resource does not exist in the current organization.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_not_found'
        '409':
          description: >-
            The order changed since expected_revision, an agreement finding
            changed since it was read, the terms cannot change while a proposed
            revision waits (proposal_waiting), the proposed revision was already
            decided or replaced (stale_proposal), agreement prices need approval
            (approval_required), the status change is not allowed, no approval
            waits for a decision or another one than you reviewed is pending, an
            issued order already uses the number for this buyer, a native order
            was pushed to an ERP, or its push is queued or running, and so
            cannot change supplier, buyer, currency or commitment basis, an open
            order cannot be archived, or only a draft can be deleted.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: conflict
                  message: >-
                    The order changed since expected_revision, an agreement
                    finding changed since it was read, the terms cannot change
                    while a proposed revision waits (proposal_waiting), the
                    proposed revision was already decided or replaced
                    (stale_proposal), agreement prices need approval
                    (approval_required), the status change is not allowed, no
                    approval waits for a decision or another one than you
                    reviewed is pending, an issued order already uses the number
                    for this buyer, a native order was pushed to an ERP, or its
                    push is queued or running, and so cannot change supplier,
                    buyer, currency or commitment basis, an open order cannot be
                    archived, or only a draft can be deleted.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_conflict'
        '429':
          description: Too many requests. Wait for the Retry-After delay before retrying.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
            Retry-After:
              schema:
                type: string
                example: '60'
              required: true
              description: Seconds to wait before retrying the request.
          content:
            application/json:
              example:
                error:
                  code: rate_limit_exceeded
                  message: >-
                    Too many requests. Wait for the Retry-After delay before
                    retrying.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_rate_limit_exceeded'
        '500':
          description: >-
            Unexpected server failure. Include the request ID when contacting
            support.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
          content:
            application/json:
              example:
                error:
                  code: internal_error
                  message: >-
                    Unexpected server failure. Include the request ID when
                    contacting support.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_internal_error'
        '503':
          description: >-
            Temporarily unavailable. Retry after the Retry-After delay, when
            provided.
          headers:
            X-Request-Id:
              schema:
                type: string
              required: true
              description: >-
                Request ID, also included in error bodies. Include it when
                contacting support.
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
                  - private, no-store, no-transform
              required: false
              description: API responses are private and must not be cached.
            X-RateLimit-Limit:
              schema:
                type: string
                example: '500'
              required: false
              description: >-
                Requests allowed per minute for this credential, or failed API
                key attempts allowed per minute from this IP address.
            Retry-After:
              schema:
                type: string
                example: '60'
              required: true
              description: Seconds to wait before retrying the request.
          content:
            application/json:
              example:
                error:
                  code: service_unavailable
                  message: >-
                    Temporarily unavailable. Retry after the Retry-After delay,
                    when provided.
                  request_id: req_example
              schema:
                $ref: '#/components/schemas/Error_service_unavailable'
      security:
        - ApiKeyBearer: []
components:
  schemas:
    PurchaseOrderLineCreate:
      type: object
      properties:
        item:
          type: object
          properties:
            name:
              type: string
              minLength: 1
              maxLength: 500
            description:
              type:
                - string
                - 'null'
              maxLength: 5000
              default: null
            product_code:
              type:
                - string
                - 'null'
              maxLength: 200
              default: null
            buyer_product_code:
              type:
                - string
                - 'null'
              maxLength: 200
              default: null
          required:
            - name
          additionalProperties: false
        quantity:
          type: string
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
        unit:
          type:
            - string
            - 'null'
          maxLength: 200
          default: null
        unit_price:
          type: string
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
        kind:
          type: string
          enum:
            - item
            - allowance
            - charge
          description: >-
            item: goods or services. allowance: a discount the document lists on
            its own, priced zero or below. charge: a fee, freight or surcharge
            listed on its own, priced zero or above. Neither names the lines it
            applies to. Omitted on a new line, a negative price makes it an
            allowance and any other an item.
        gross_unit_price:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          default: null
          description: >-
            Peppol Price/AllowanceCharge/BaseAmount: the price per unit printed
            before the line's own discount, for display only. unit_price is the
            binding net price. Only on an item, at or above unit_price. Changing
            unit_price or kind without it clears it.
        vat_rate:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          default: null
          description: >-
            The VAT rate the supplier charges, as a fraction (0.25 is 25 %);
            null for none. A higher rate on an invoice is a vat_rate finding.
        agreement_item_id:
          type:
            - string
            - 'null'
          format: uuid
          default: null
          description: >-
            The agreement price the line is ordered from, one of the order's
            agreement prices.
        coding:
          type:
            - object
            - 'null'
          properties:
            ledger_account_id:
              type:
                - string
                - 'null'
              format: uuid
              default: null
            vat_code_id:
              type:
                - string
                - 'null'
              format: uuid
              default: null
            dimension_value_ids:
              type: array
              items:
                type: string
                format: uuid
              maxItems: 50
              default: []
              description: Dimension values, at most one per dimension.
          default: null
          additionalProperties: false
          description: >-
            Where the line's cost is booked: an account, a VAT code and
            dimension values from the chart of accounts (listLedgerAccounts,
            listVatCodes, listDimensionValues). Not a term: changing it records
            no revision. An invoice line matched to the order line takes it as
            its coding suggestion.
        source_line_id:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 200
          default: null
          description: >-
            The line's ID in the order's other system, unique within the order.
            Only on an order linked to that system with source; receipts can
            name the line by it.
      required:
        - item
        - quantity
        - unit_price
      additionalProperties: false
    PurchaseOrderLineUpdate:
      type: object
      properties:
        id:
          type: string
          format: uuid
        item:
          type: object
          properties:
            name:
              type: string
              minLength: 1
              maxLength: 500
            description:
              type:
                - string
                - 'null'
              maxLength: 5000
            product_code:
              type:
                - string
                - 'null'
              maxLength: 200
            buyer_product_code:
              type:
                - string
                - 'null'
              maxLength: 200
          additionalProperties: false
        quantity:
          type: string
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
        unit:
          type:
            - string
            - 'null'
          maxLength: 200
        unit_price:
          type: string
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
        kind:
          type: string
          enum:
            - item
            - allowance
            - charge
          description: >-
            As on create. Omitted with a new unit_price, a negative charge
            becomes an allowance and a positive allowance an item.
        gross_unit_price:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: As on create.
        vat_rate:
          type:
            - string
            - 'null'
          maxLength: 100
          pattern: ^-?\d+(?:\.\d+)?$
          description: As on create.
        coding:
          type:
            - object
            - 'null'
          properties:
            ledger_account_id:
              type:
                - string
                - 'null'
              format: uuid
              default: null
            vat_code_id:
              type:
                - string
                - 'null'
              format: uuid
              default: null
            dimension_value_ids:
              type: array
              items:
                type: string
                format: uuid
              maxItems: 50
              default: []
              description: Dimension values, at most one per dimension.
          additionalProperties: false
          description: As on create.
        source_line_id:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 200
          description: As on create.
      required:
        - id
      additionalProperties: false
    PurchaseOrderInvoiceApproversInput:
      anyOf:
        - type: object
          properties:
            user_ids:
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 200
                pattern: ^[A-Za-z0-9_-]+$
              maxItems: 20
              default: []
              description: Members who approve in this step.
            team_ids:
              type: array
              items:
                type: string
                format: uuid
              maxItems: 20
              default: []
              description: >-
                Teams that approve in this step; any one member decides for the
                team.
          additionalProperties: false
          description: 'One step: the approvers are asked together.'
        - type: object
          properties:
            steps:
              type: array
              items:
                type: object
                properties:
                  user_ids:
                    type: array
                    items:
                      type: string
                      minLength: 1
                      maxLength: 200
                      pattern: ^[A-Za-z0-9_-]+$
                    maxItems: 20
                    default: []
                    description: Members who approve in this step.
                  team_ids:
                    type: array
                    items:
                      type: string
                      format: uuid
                    maxItems: 20
                    default: []
                    description: >-
                      Teams that approve in this step; any one member decides
                      for the team.
                additionalProperties: false
              maxItems: 10
              description: >-
                The approvers in steps, first step first. Steps set only the
                order: one approval completes a step and the next step's
                approvers are asked; the invoice is approved at the
                organization's number of approvals, however many steps there
                are. Steps without approvers are left out.
          required:
            - steps
          additionalProperties: false
      description: >-
        Who approves the invoices matched to the order, apart from the order's
        own approvers: user_ids and team_ids for one step, or steps. Replaces
        the whole list, needs no revision and applies to imported orders too; an
        empty list leaves the order's invoices to the approval rules. An invoice
        gets them, in their steps, when Watchdog has read and checked it, in
        place of the rules' approvers; invoices already past that keep theirs.
        On create, left out, it is the owner.
    PurchaseOrderApprovalDecision:
      oneOf:
        - type: object
          properties:
            decision:
              type: string
              enum:
                - approved
            request_id:
              type: string
              format: uuid
            commitment:
              type:
                - string
                - 'null'
              maxLength: 100
              pattern: ^-?\d+(?:\.\d+)?$
              description: >-
                The commitment you reviewed: a draft's `totals.commitment`, or a
                proposed revision's `proposed_revision.totals.commitment`. When
                a draft's commitment has risen since, approving is a conflict.
          required:
            - decision
            - request_id
            - commitment
          additionalProperties: false
        - type: object
          properties:
            decision:
              type: string
              enum:
                - rejected
            request_id:
              type: string
              format: uuid
            reason:
              type: string
              maxLength: 2000
              description: Why the order is rejected. Optional; empty counts as none.
          required:
            - decision
            - request_id
          additionalProperties: false
      description: >-
        Decide the order's pending approval request as one of its approvers,
        sent on its own. approved opens a waiting draft or applies the proposed
        revision as the next one; rejected keeps a draft a draft and discards a
        proposed revision. `request_id` is `approval.id` from the order you
        reviewed; another pending request is a conflict. Approving needs
        `commitment`, the commitment you reviewed (null when none): a draft's
        `totals.commitment`, which must not have risen since, or a proposed
        revision's `totals.commitment`. A draft with supplier-proposed changes
        still waiting returns 409 (proposal_waiting): decide them first. A
        member who added themselves while an approval rule also chose approvers
        cannot approve (403).
    PurchaseOrderProposalDecision:
      type: object
      properties:
        id:
          type: string
          format: uuid
        decision:
          type: string
          enum:
            - accept
            - reject
      required:
        - id
        - decision
      additionalProperties: false
      description: >-
        Accept or reject the order's proposed revision, sent on its own. `id` is
        `proposed_revision.id` from the order you reviewed; another one is a
        conflict. accept applies it as the next revision when any member decides
        it (`decided_by` members); one its approvers decide is accepted by
        approving it (approval). One that needs approval since it was proposed
        is sent to its approvers instead. reject discards it, also one waiting
        for approval, and the order stays as it is.
    PurchaseOrder:
      type: object
      properties:
        company_id:
          type: string
          format: uuid
          description: >-
            The company that places the order. Its buyer is the company's own
            recipient, unless an imported order names another.
        id:
          type: string
          format: uuid
        number:
          type:
            - string
            - 'null'
        title:
          type:
            - string
            - 'null'
        status:
          type: string
          enum:
            - draft
            - open
            - closed
            - cancelled
          description: >-
            closed means closed for invoicing, set by a person; it is not
            derived from an ERP receipt status. Waiting for approval is not a
            status: see awaiting_approval.
        awaiting_approval:
          type: boolean
          description: >-
            The order has an approval request pending: a draft opens once
            approved; on an opened order it decides the proposed revision, while
            the current revision stays in force and can be sent and pushed.
        approvers:
          type: array
          items:
            type: object
            properties:
              user_id:
                type: string
                minLength: 1
                maxLength: 200
                pattern: ^[A-Za-z0-9_-]+$
              first_name:
                type:
                  - string
                  - 'null'
              last_name:
                type:
                  - string
                  - 'null'
              email:
                type:
                  - string
                  - 'null'
            required:
              - user_id
              - first_name
              - last_name
              - email
          description: >-
            The people the pending approval request waits for, in the order they
            were added; empty when none is pending. Teams it waits for are on
            approval.approver_teams. Who decided an earlier request is on
            approval.
        archived:
          type: boolean
        supplier:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
            organization_number:
              type:
                - string
                - 'null'
          required:
            - id
            - name
            - organization_number
        buyer:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
            organization_number:
              type:
                - string
                - 'null'
          required:
            - id
            - name
            - organization_number
          description: 'A recipient: the legal entity that placed the order.'
        owner_user_id:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 200
          pattern: ^[A-Za-z0-9_-]+$
        agreement:
          type:
            - object
            - 'null'
          properties:
            id:
              type:
                - string
                - 'null'
              format: uuid
            title:
              type:
                - string
                - 'null'
            origin:
              type: string
              enum:
                - manual
                - automatic
            restricted:
              type: boolean
              description: >-
                True when the caller cannot see the agreement; id and title are
                then null.
          required:
            - id
            - title
            - origin
            - restricted
        currency_code:
          type:
            - string
            - 'null'
        commitment_basis:
          type: string
          enum:
            - lines
            - amount_limit
          description: >-
            lines: the order commits to its active lines. amount_limit: it
            commits to amount_limit for the scope in scope_description; its
            lines are price references.
        totals:
          type: object
          properties:
            lines_excluding_vat:
              type: string
              pattern: ^-?\d+(?:\.\d+)?$
              description: Active lines, excluding VAT.
            commitment:
              type:
                - string
                - 'null'
              pattern: ^-?\d+(?:\.\d+)?$
              description: >-
                Active lines for a lines order, amount_limit for an amount-limit
                order.
            expected:
              type:
                - string
                - 'null'
              pattern: ^-?\d+(?:\.\d+)?$
              description: >-
                What the order is expected to cost, excluding VAT: the budget,
                when set, while a lines order has no active lines; otherwise
                commitment.
          required:
            - lines_excluding_vat
            - commitment
            - expected
        billing:
          $ref: '#/components/schemas/PurchaseOrderBilling'
        revision:
          type:
            - integer
            - 'null'
          description: The current commercial revision; null for a draft.
        open_alert_count:
          type: integer
          minimum: 0
          description: >-
            Visible, live alerts from checking the order's invoices against it:
            neither dismissed, skipped nor credited.
        valid_until:
          type:
            - string
            - 'null'
        origin:
          type: string
          enum:
            - native
            - imported
          description: >-
            Where the order was born and is edited: `native` in Watchdog,
            `imported` in the ERP in `source`.
        source:
          $ref: '#/components/schemas/PurchaseOrderSource'
        from_import:
          type: boolean
          description: >-
            Drafted from documents through createPurchaseOrderImport; import has
            the details.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        lifecycle:
          $ref: '#/components/schemas/PurchaseOrderLifecycle'
        emails:
          type: object
          properties:
            message:
              type: boolean
              description: A message to the supplier can be sent.
            price_request:
              type: boolean
              description: 'A price request can be sent: a draft.'
            order:
              type: boolean
              description: 'The order can be sent by email: an open order.'
          required:
            - message
            - price_request
            - order
          description: >-
            Which emails the order may send its supplier, as the send endpoints
            enforce them. None for an imported or archived order; messages also
            after it is closed or cancelled.
        status_reason:
          type:
            - string
            - 'null'
        owner:
          type:
            - object
            - 'null'
          properties:
            user_id:
              type: string
              minLength: 1
              maxLength: 200
              pattern: ^[A-Za-z0-9_-]+$
            first_name:
              type:
                - string
                - 'null'
            last_name:
              type:
                - string
                - 'null'
            email:
              type:
                - string
                - 'null'
          required:
            - user_id
            - first_name
            - last_name
            - email
        invoice_approvers:
          $ref: '#/components/schemas/PurchaseOrderInvoiceApprovers'
        amount_limit:
          type:
            - string
            - 'null'
          pattern: ^-?\d+(?:\.\d+)?$
          description: Excluding VAT.
        unordered_charges:
          type: string
          enum:
            - flag
            - accept
          description: >-
            Invoice lines the order's lines don't cover, like freight: flag
            raises an unordered_charge alert, accept accepts them up to
            unordered_charges_limit.
        unordered_charges_limit:
          type:
            - string
            - 'null'
          pattern: ^-?\d+(?:\.\d+)?$
          description: >-
            Set only with accept: the most accepted across the order's invoices,
            excluding VAT; null accepts them all.
        scope_description:
          type:
            - string
            - 'null'
        issued_date:
          type:
            - string
            - 'null'
        valid_from:
          type:
            - string
            - 'null'
        delivery_date:
          type:
            - string
            - 'null'
          description: When the goods or service are expected. Needed to push the order.
        delivery:
          $ref: '#/components/schemas/PurchaseOrderDelivery'
        buyer_reference:
          type:
            - string
            - 'null'
          description: >-
            While a draft, empty or still the owner's name, it follows the
            owner's name. A reference a person writes stays.
        sales_order_reference:
          type:
            - string
            - 'null'
          description: The supplier's order or confirmation number (Peppol SalesOrderID).
        contract_reference:
          type:
            - string
            - 'null'
          description: >-
            While a draft, empty or still the linked agreement's number, it
            follows the agreement's number.
        project_reference:
          type:
            - string
            - 'null'
          description: >-
            While a draft, empty or still the code of the order's project (its
            value of a project dimension), it follows that code.
        dimension_values:
          type: array
          items:
            type: object
            properties:
              dimension_id:
                type: string
                format: uuid
              dimension_name:
                type: string
              dimension_kind:
                type: string
                enum:
                  - department
                  - project
                  - custom
                description: >-
                  The dimension's kind: a project's value fills the order's
                  project reference.
              id:
                type: string
                format: uuid
              name:
                type: string
              usable:
                type: boolean
                description: >-
                  Active and still in the chart of accounts; a line keeps a code
                  that went.
              code:
                type:
                  - string
                  - 'null'
            required:
              - dimension_id
              - dimension_name
              - dimension_kind
              - id
              - name
              - usable
              - code
          description: >-
            Where the order's cost is booked, in its company: each line takes
            these, except where it holds its own value for that dimension, and
            invoices billing the order take them as coding suggestions. Not part
            of the terms, so revisions leave it out.
        note_to_supplier:
          type:
            - string
            - 'null'
          description: >-
            Free text for the supplier, printed on the order (Peppol Order
            Note).
        internal_note:
          type:
            - string
            - 'null'
        budget:
          type:
            - string
            - 'null'
          pattern: ^-?\d+(?:\.\d+)?$
          description: >-
            Excluding VAT, internal: what the organization expects to spend.
            Never printed, sent or pushed.
        billing_review:
          $ref: '#/components/schemas/PurchaseOrderBillingReview'
        invoice_checks:
          type: object
          properties:
            checked:
              type: integer
              minimum: 0
              description: Accepted invoices with a completed check.
          required:
            - checked
          description: >-
            Checks of the accepted invoices against this order, counted over
            every invoice like billing.
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseOrderLine'
        push_targets:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseOrderPushTarget'
          description: >-
            Connections a native order can be pushed to; empty once the ERP
            holds it, and for imported orders.
        latest_push:
          $ref: '#/components/schemas/PurchaseOrderLatestPush'
        push_readiness:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
              field:
                type: string
              message:
                type: string
            required:
              - code
              - field
              - message
          description: >-
            What the order is missing before it can be pushed; empty when it is
            ready.
        to_fill:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseOrderToFill'
          description: >-
            What an order made in Watchdog should still get: each dimension the
            organization requires that a draft does not carry yet (opening needs
            it), then the agreements that may cover it, while it links none.
            Fill each, or ask the person. Empty when nothing is missing, and for
            orders synced from an accounting system.
        sent_to_supplier:
          $ref: '#/components/schemas/PurchaseOrderSentToSupplier'
        supplier_revision:
          type:
            - integer
            - 'null'
          description: >-
            The latest revision whose terms the supplier has, or may have: sent
            through Watchdog or marked as sent outside it (sendPurchaseOrder),
            made by accepting the supplier's own proposal, or revision 1 of an
            order they confirmed before it opened. Null when they have none.
        placement:
          type: string
          enum:
            - watchdog
            - external
          description: >-
            watchdog: placed through Watchdog, with its approval and send.
            external: ordered outside Watchdog (a web shop, the phone) and
            recorded here; it needed no order approval and is not sent.
        approval:
          $ref: '#/components/schemas/PurchaseOrderApproval'
        approval_required:
          type: boolean
          description: >-
            A draft that an approval rule for orders matches: opening it asks
            for approval instead. False for opened and imported orders.
        opened_at:
          type:
            - string
            - 'null'
          format: date-time
        closed_at:
          type:
            - string
            - 'null'
          format: date-time
        cancelled_at:
          type:
            - string
            - 'null'
          format: date-time
        archived_at:
          type:
            - string
            - 'null'
          format: date-time
        import:
          $ref: '#/components/schemas/PurchaseOrderImportState'
        proposed_revision:
          $ref: '#/components/schemas/PurchaseOrderProposedRevision'
        supplier_reply:
          $ref: '#/components/schemas/PurchaseOrderSupplierReply'
      required:
        - company_id
        - id
        - number
        - title
        - status
        - awaiting_approval
        - approvers
        - archived
        - supplier
        - buyer
        - owner_user_id
        - agreement
        - currency_code
        - commitment_basis
        - totals
        - billing
        - revision
        - open_alert_count
        - valid_until
        - origin
        - source
        - from_import
        - created_at
        - updated_at
        - lifecycle
        - emails
        - status_reason
        - owner
        - invoice_approvers
        - amount_limit
        - unordered_charges
        - unordered_charges_limit
        - scope_description
        - issued_date
        - valid_from
        - delivery_date
        - delivery
        - buyer_reference
        - sales_order_reference
        - contract_reference
        - project_reference
        - dimension_values
        - note_to_supplier
        - internal_note
        - budget
        - billing_review
        - invoice_checks
        - line_items
        - push_targets
        - latest_push
        - push_readiness
        - to_fill
        - sent_to_supplier
        - supplier_revision
        - placement
        - approval
        - approval_required
        - opened_at
        - closed_at
        - cancelled_at
        - archived_at
        - import
        - proposed_revision
        - supplier_reply
    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
    PurchaseOrderBilling:
      type: object
      properties:
        linked_invoices:
          type: integer
          minimum: 0
        billed:
          type: string
        remaining:
          type:
            - string
            - 'null'
        excess:
          type:
            - string
            - 'null'
        authoritative:
          type: boolean
        coverage:
          type: object
          properties:
            pending_suggestions:
              type: integer
              minimum: 0
            unsupported_credits:
              type: integer
              minimum: 0
            incompatible_invoices:
              type: integer
              minimum: 0
            invalid_invoices:
              type: integer
              minimum: 0
            unassigned_invoices:
              type: integer
              minimum: 0
            reconciliation_pending:
              type: boolean
          required:
            - pending_suggestions
            - unsupported_credits
            - incompatible_invoices
            - invalid_invoices
            - unassigned_invoices
            - reconciliation_pending
        untied:
          type:
            - object
            - 'null'
          properties:
            lines:
              type: integer
              minimum: 0
            amount:
              type: string
          required:
            - lines
            - amount
      required:
        - linked_invoices
        - billed
        - remaining
        - excess
        - authoritative
        - coverage
        - untied
    PurchaseOrderSource:
      type:
        - object
        - 'null'
      properties:
        system:
          type: string
          description: >-
            The other system: an ERP, such as tripletex, or the name the creator
            gave.
        id:
          type: string
          description: That system's own ID for the order.
        number:
          type:
            - string
            - 'null'
          description: >-
            That system's number for the order; for a pushed order, the one the
            ERP assigned. Invoices citing it match the order.
        channel:
          type: string
          enum:
            - integration
            - api
          description: >-
            `integration`: a connection imports or pushes the order and keeps
            the fields below. `api`: linked when the order was created; nothing
            syncs it.
        status:
          type:
            - string
            - 'null'
          description: That system's own status for the order, as given.
        refreshed_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When the ERP and Watchdog last agreed on the order; null while a
            push is unfinished.
        synced_revision:
          type:
            - integer
            - 'null'
          description: >-
            The revision the ERP verifiably holds; null while a push is
            unfinished.
        pending:
          type: boolean
          description: >-
            A native order's current revision is not in the ERP yet: never
            pushed, or amended since.
      required:
        - system
        - id
        - number
        - channel
        - status
        - refreshed_at
        - synced_revision
        - pending
      description: >-
        The order's ERP. An imported order's terms, lines and cancellation
        change there and the next sync brings them in; a native order is pushed
        there and its copy follows Watchdog.
    PurchaseOrderLifecycle:
      type: object
      properties:
        status:
          type: string
          enum:
            - draft
            - awaiting_approval
            - open
            - closed
            - cancelled
          description: >-
            Where the order is in its life: its status, except that a draft with
            an approval request pending reads awaiting_approval. An open order
            whose proposed revision waits for approval stays open. Read-only;
            set the order's status through PATCH.
        blockers:
          type: array
          items:
            type: string
            enum:
              - archived
              - no_number
              - no_supplier
              - no_buyer
              - no_currency
              - no_lines
              - negative_total
              - no_amount_limit
              - no_scope
              - no_required_dimension
          description: >-
            What opening the order would be refused for, as PATCH with status
            open refuses it: archived (restore it first), then what it is
            missing (no_required_dimension: a dimension the organization
            requires on orders, settings.purchase_order_required_dimensions).
            Only for draft and awaiting_approval, empty otherwise. A number
            another order took is found only when it opens.
        next_action:
          type:
            - object
            - 'null'
          properties:
            kind:
              type: string
              enum:
                - restore
                - record_ordered
                - approve
                - await_approval
                - decide_proposal
                - ask_price
                - await_supplier
                - request_approval
                - open
                - open_and_send
                - send
                - close
              description: >-
                restore: unarchive it. record_ordered: save an order placed
                outside Watchdog as ordered. approve: decide its approval
                request. await_approval: its approvers decide. decide_proposal:
                accept or reject the proposed revision. ask_price: ask the
                supplier for a price. await_supplier: the supplier has not
                answered the price request. request_approval: open it, which
                asks for approval. open: open it; the supplier already confirmed
                it. open_and_send: open it and send it to the supplier. send:
                send the current revision to the supplier. close: it is invoiced
                to its value.
            mine:
              type: boolean
              description: Whether the caller may take this step.
            waiting_on:
              type: array
              items:
                type: string
              description: >-
                User IDs of whoever else the step waits on, for await_approval;
                empty otherwise.
            disabled_by:
              type: array
              items:
                type: string
                enum:
                  - archived
                  - no_number
                  - no_supplier
                  - no_buyer
                  - no_currency
                  - no_lines
                  - negative_total
                  - no_amount_limit
                  - no_scope
                  - no_required_dimension
              description: >-
                What must be fixed before the step can be taken; empty when it
                can be now.
          required:
            - kind
            - mine
            - waiting_on
            - disabled_by
          description: >-
            The order's one next step. Null when nothing waits, and always for
            an imported order, which its accounting system decides.
      required:
        - status
        - blockers
        - next_action
    PurchaseOrderInvoiceApprovers:
      type: object
      properties:
        people:
          type: array
          items:
            type: object
            properties:
              user_id:
                type: string
                minLength: 1
                maxLength: 200
                pattern: ^[A-Za-z0-9_-]+$
              first_name:
                type:
                  - string
                  - 'null'
              last_name:
                type:
                  - string
                  - 'null'
              email:
                type:
                  - string
                  - 'null'
              step:
                type: integer
                exclusiveMinimum: 0
                description: >-
                  The approver's step, from 1. Steps set only the order in which
                  the invoice's approvers are asked; the invoice is approved at
                  the organization's number of approvals, however many steps
                  there are.
            required:
              - user_id
              - first_name
              - last_name
              - email
              - step
        teams:
          type: array
          items:
            type: object
            properties:
              team_id:
                type: string
                format: uuid
              name:
                type: string
              step:
                type: integer
                exclusiveMinimum: 0
                description: >-
                  The approver's step, from 1. Steps set only the order in which
                  the invoice's approvers are asked; the invoice is approved at
                  the organization's number of approvals, however many steps
                  there are.
            required:
              - team_id
              - name
              - step
      required:
        - people
        - teams
      description: >-
        Who approves the invoices matched to the order, by step and then in the
        order they were added; not approval.approvers, who approve the order
        itself. An invoice that bills the order gets them in their steps once
        Watchdog has read and checked it, in place of the approval rules'
        approvers. Set with updatePurchaseOrder invoice_approvers.
    PurchaseOrderDelivery:
      type:
        - object
        - 'null'
      properties:
        name:
          type:
            - string
            - 'null'
          description: Who receives the delivery (Peppol DeliveryParty name).
        address:
          type: object
          properties:
            street:
              type:
                - string
                - 'null'
            postal_code:
              type:
                - string
                - 'null'
            city:
              type:
                - string
                - 'null'
            country_code:
              type:
                - string
                - 'null'
              description: ISO 3166-1 alpha-2.
          required:
            - street
            - postal_code
            - city
            - country_code
          description: Peppol Delivery/DeliveryLocation/Address.
      required:
        - name
        - address
      description: >-
        Where to deliver. Null delivers to the buyer's own address. Changing it
        on an opened order records a revision.
    PurchaseOrderBillingReview:
      type: object
      properties:
        amount_status:
          type: string
          enum:
            - unknown
            - not_invoiced
            - partial
            - at_value
            - over
        single_invoice:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            number:
              type:
                - string
                - 'null'
          required:
            - id
            - number
        quantity:
          type: object
          properties:
            single_invoice_id:
              type:
                - string
                - 'null'
              format: uuid
            lines:
              type: integer
              minimum: 0
            invoices:
              type: integer
              minimum: 0
            amount:
              type:
                - string
                - 'null'
          required:
            - single_invoice_id
            - lines
            - invoices
            - amount
        received:
          type: object
          properties:
            single_invoice_id:
              type:
                - string
                - 'null'
              format: uuid
            lines:
              type: integer
              minimum: 0
            invoices:
              type: integer
              minimum: 0
            amount:
              type:
                - string
                - 'null'
          required:
            - single_invoice_id
            - lines
            - invoices
            - amount
          description: >-
            Invoiced within the order but above what was received, on orders
            that record receipts.
        unit_price:
          type: object
          properties:
            single_invoice_id:
              type:
                - string
                - 'null'
              format: uuid
            lines:
              type: integer
              minimum: 0
            invoices:
              type: integer
              minimum: 0
            amount:
              type:
                - string
                - 'null'
          required:
            - single_invoice_id
            - lines
            - invoices
            - amount
        vat_rate:
          type: object
          properties:
            single_invoice_id:
              type:
                - string
                - 'null'
              format: uuid
            lines:
              type: integer
              minimum: 0
            invoices:
              type: integer
              minimum: 0
            amount:
              type:
                - string
                - 'null'
          required:
            - single_invoice_id
            - lines
            - invoices
            - amount
          description: Invoiced at a higher VAT rate than the order line states.
        unmatched:
          type: object
          properties:
            single_invoice_id:
              type:
                - string
                - 'null'
              format: uuid
            lines:
              type: integer
              minimum: 0
            invoices:
              type: integer
              minimum: 0
            amount:
              type:
                - string
                - 'null'
          required:
            - single_invoice_id
            - lines
            - invoices
            - amount
        lines:
          type: array
          items:
            type: object
            properties:
              purchase_order_line_id:
                type: string
                format: uuid
              codes:
                type: array
                items:
                  type: string
                  enum:
                    - quantity
                    - received
                    - unit_price
                    - vat_rate
            required:
              - purchase_order_line_id
              - codes
          description: >-
            Order lines with an unresolved quantity, receipt, unit price or VAT
            rate finding, by the same predicates as the categories. A grouped
            invoice line names every order line it covers.
      required:
        - amount_status
        - single_invoice
        - quantity
        - received
        - unit_price
        - vat_rate
        - unmatched
        - lines
      description: >-
        Visible unresolved billing findings. Single invoice is exposed only when
        exactly one live accepted invoice exists and is accessible.
    PurchaseOrderLine:
      type: object
      properties:
        id:
          type: string
          format: uuid
        billed_amount:
          type: string
        invoice_summary:
          type:
            - object
            - 'null'
          properties:
            invoices:
              type: integer
              minimum: 0
            unit_price_min:
              type:
                - string
                - 'null'
            unit_price_max:
              type:
                - string
                - 'null'
            unit_price_difference:
              type:
                - string
                - 'null'
            price_difference_invoices:
              type:
                - integer
                - 'null'
              minimum: 0
            grouped_invoice_lines:
              type: array
              items:
                type: object
                properties:
                  invoice_id:
                    type: string
                    format: uuid
                  invoice_number:
                    type:
                      - string
                      - 'null'
                  invoice_item_id:
                    type: string
                    format: uuid
                  line_number:
                    type: integer
                  description:
                    type:
                      - string
                      - 'null'
                  purchase_order_line_ids:
                    type: array
                    items:
                      type: string
                      format: uuid
                    description: >-
                      Every order line the invoice line bills, this one
                      included.
                required:
                  - invoice_id
                  - invoice_number
                  - invoice_item_id
                  - line_number
                  - description
                  - purchase_order_line_ids
              description: >-
                Invoice lines that bill this line as part of a group, together
                with other lines of the order.
          required:
            - invoices
            - unit_price_min
            - unit_price_max
            - unit_price_difference
            - price_difference_invoices
            - grouped_invoice_lines
          description: >-
            Accepted invoices allocated to this line. Null if any invoice is
            restricted. Effective unit prices include line adjustments; a
            grouped invoice line counts what it bills this line. Null when units
            or quantities cannot be compared.
        invoice_check:
          type:
            - string
            - 'null'
          enum:
            - clean
            - findings
            - incomplete
            - null
          description: >-
            The purchase-order check's verdict on the accepted invoices that
            bill this line: findings when an open quantity or unit price finding
            names the line; clean when every one was checked completely without
            one; incomplete otherwise. Null when no accepted invoice bills the
            line, the line is cancelled, or an invoice is restricted.
        billed_quantity:
          type:
            - string
            - 'null'
        quantity_complete:
          type: boolean
        billed_unit:
          type:
            - string
            - 'null'
          description: >-
            The unit billed_quantity is in: the Peppol code, or the unit as
            written when it has none. A line without a unit takes the unit its
            billed invoice lines share.
        line_reference:
          type: string
          description: >-
            The line identifier as the supplier sees it (Peppol LineItem/ID).
            Never reused once the order is opened; lines are listed in their
            display order. Invoice lines are never matched on it.
        item:
          type: object
          properties:
            name:
              type: string
            description:
              type:
                - string
                - 'null'
            product_code:
              type:
                - string
                - 'null'
              description: The seller's article number.
            buyer_product_code:
              type:
                - string
                - 'null'
              description: The buyer's own article number.
          required:
            - name
            - description
            - product_code
            - buyer_product_code
        quantity:
          type: string
          pattern: ^-?\d+(?:\.\d+)?$
        unit:
          type:
            - string
            - 'null'
          description: As written, such as pcs or hours.
        unit_price:
          type: string
          pattern: ^-?\d+(?:\.\d+)?$
          description: >-
            The agreed net price per unit after the line's own discounts,
            excluding VAT. Zero or below on an allowance, zero or above on a
            charge.
        total_excluding_vat:
          type: string
          pattern: ^-?\d+(?:\.\d+)?$
          description: quantity × unit_price.
        vat_rate:
          type:
            - string
            - 'null'
          pattern: ^-?\d+(?:\.\d+)?$
          description: >-
            The VAT rate the supplier is to charge, as a fraction: 0.25 is 25 %.
            Null when the order states none. A term: an invoice line billing the
            line at a higher rate is a vat_rate finding.
        kind:
          type: string
          enum:
            - item
            - allowance
            - charge
          description: >-
            Peppol: item for goods or services; allowance for a discount and
            charge for a fee, freight or surcharge the document lists on its
            own. Neither names the lines it applies to, and neither is spread
            over them.
        gross_unit_price:
          type:
            - string
            - 'null'
          pattern: ^-?\d+(?:\.\d+)?$
          description: >-
            Peppol Price/AllowanceCharge/BaseAmount: the price per unit printed
            before the line's own discount, for display only; unit_price is the
            binding net price. Only on an item. Not part of the terms, so
            revisions leave it out.
        status:
          type: string
          enum:
            - active
            - cancelled
          description: >-
            A line removed from an opened order is cancelled; it keeps its ID
            and number.
        agreement_item_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            The agreement price the line was ordered from; null when it has none
            or you cannot see its agreement. Not part of the terms, so revisions
            leave it out.
        source_line_id:
          type:
            - string
            - 'null'
          description: >-
            The line's ID in the order's other system (source): the ERP's on an
            imported or pushed order, the caller's on a linked one. Not part of
            the terms, so revisions leave it out.
        coding:
          type:
            - object
            - 'null'
          properties:
            account:
              type:
                - object
                - 'null'
              properties:
                id:
                  type: string
                  format: uuid
                name:
                  type: string
                usable:
                  type: boolean
                  description: >-
                    Active and still in the chart of accounts; a line keeps a
                    code that went.
                number:
                  type:
                    - string
                    - 'null'
              required:
                - id
                - name
                - usable
                - number
            vat_code:
              type:
                - object
                - 'null'
              properties:
                id:
                  type: string
                  format: uuid
                name:
                  type: string
                usable:
                  type: boolean
                  description: >-
                    Active and still in the chart of accounts; a line keeps a
                    code that went.
                code:
                  type:
                    - string
                    - 'null'
                rate:
                  type:
                    - string
                    - 'null'
                  pattern: ^-?\d+(?:\.\d+)?$
              required:
                - id
                - name
                - usable
                - code
                - rate
            dimension_values:
              type: array
              items:
                type: object
                properties:
                  dimension_id:
                    type: string
                    format: uuid
                  dimension_name:
                    type: string
                  dimension_kind:
                    type: string
                    enum:
                      - department
                      - project
                      - custom
                    description: >-
                      The dimension's kind: a project's value fills the order's
                      project reference.
                  id:
                    type: string
                    format: uuid
                  name:
                    type: string
                  usable:
                    type: boolean
                    description: >-
                      Active and still in the chart of accounts; a line keeps a
                      code that went.
                  code:
                    type:
                      - string
                      - 'null'
                required:
                  - dimension_id
                  - dimension_name
                  - dimension_kind
                  - id
                  - name
                  - usable
                  - code
          required:
            - account
            - vat_code
            - dimension_values
          description: >-
            Where the line's cost is booked; null when it is not coded. An
            invoice line matched to the order line takes it as its coding
            suggestion. Not part of the terms, so revisions leave it out.
        received:
          type:
            - object
            - 'null'
          properties:
            quantity:
              type: string
              pattern: ^-?\d+(?:\.\d+)?$
              description: Everything received on the line, in `unit`.
            unit:
              type:
                - string
                - 'null'
              description: >-
                The unit the quantity counts, as written: the line's when it was
                recorded, unless receiving gave another.
            last_received_on:
              type: string
              format: date
              description: When the received quantity last changed.
          required:
            - quantity
            - unit
            - last_received_on
          description: >-
            Goods received on the line (recordPurchaseOrderReceipts); null until
            a total is recorded. Invoices billing more than was received are
            flagged on orders that record goods received, while the received
            unit agrees with the line's.
      required:
        - id
        - line_reference
        - item
        - quantity
        - unit
        - unit_price
        - total_excluding_vat
        - vat_rate
        - kind
        - status
    PurchaseOrderPushTarget:
      type: object
      properties:
        integration_id:
          type: string
          format: uuid
        integration_name:
          type: string
        system:
          type: string
          description: The accounting system, such as tripletex.
      required:
        - integration_id
        - integration_name
        - system
    PurchaseOrderLatestPush:
      type:
        - object
        - 'null'
      properties:
        workflow_run_id:
          type: string
          format: uuid
        integration_id:
          type:
            - string
            - 'null'
          format: uuid
        integration_name:
          type:
            - string
            - 'null'
        status:
          type: string
          enum:
            - queued
            - running
            - completed
            - completed_with_errors
            - failed
            - cancelled
        failure:
          type:
            - object
            - 'null'
          properties:
            code:
              type: string
            message:
              type: string
            overwritable:
              type: boolean
              description: >-
                Someone changed or deleted the order in the accounting system:
                pushing again with `overwrite` replaces their changes.
          required:
            - code
            - message
            - overwritable
      required:
        - workflow_run_id
        - integration_id
        - integration_name
        - status
        - failure
      description: The latest push of the order.
    PurchaseOrderToFill:
      oneOf:
        - type: object
          properties:
            field:
              type: string
              enum:
                - dimension
            message:
              type: string
            dimension_id:
              type: string
              format: uuid
              description: List its values with listDimensionValues dimension_ids.
            dimension_name:
              type: string
          required:
            - field
            - message
            - dimension_id
            - dimension_name
        - type: object
          properties:
            field:
              type: string
              enum:
                - agreement
            message:
              type: string
            suggestions:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  title:
                    type:
                      - string
                      - 'null'
                  reason:
                    type: string
                    enum:
                      - contract_reference
                      - parties_and_term
                    description: >-
                      contract_reference: the agreement names the order's
                      contract reference. parties_and_term: it names the
                      supplier and buyer, and its term covers the order's dates.
                required:
                  - id
                  - title
                  - reason
          required:
            - field
            - message
            - suggestions
    PurchaseOrderSentToSupplier:
      type:
        - object
        - 'null'
      properties:
        channel:
          type: string
          enum:
            - email
          description: How it was sent.
        revision:
          type: integer
          description: The latest revision sent to the supplier.
        sent_at:
          type: string
          format: date-time
        pending:
          type: boolean
          description: >-
            The order changed since the supplier last got its terms: its
            revision is newer than supplier_revision.
      required:
        - channel
        - revision
        - sent_at
        - pending
      description: >-
        The latest revision sent to the supplier through Watchdog
        (sendPurchaseOrder), counting sends that went out or may have (accepted
        or unconfirmed emails); null when none went out.
    PurchaseOrderApproval:
      type:
        - object
        - 'null'
      properties:
        id:
          type: string
          format: uuid
          description: >-
            The approval request. Send it as approval.request_id to approve or
            reject it; it changes when the request is withdrawn and asked again.
        status:
          type: string
          enum:
            - pending
            - approved
            - rejected
          description: pending until one of the approvers approves or rejects it.
        sent:
          type: boolean
          description: >-
            Whether its approvers were asked. False while it only holds the
            approvers picked on a draft: opening the draft (status open) sends
            it. Only a sent request waits for approval or can be decided.
        revision:
          type: integer
          description: >-
            The revision it decides: 1 for a draft, which opens once approved,
            or the revision a proposed change would make.
        proposal_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            The proposed revision it decides (proposed_revision.id); null for a
            draft. Approving applies it, rejecting discards it, and the order's
            current revision stays in force meanwhile.
        approvers:
          type: array
          items:
            type: object
            properties:
              user_id:
                type: string
                minLength: 1
                maxLength: 200
                pattern: ^[A-Za-z0-9_-]+$
              first_name:
                type:
                  - string
                  - 'null'
              last_name:
                type:
                  - string
                  - 'null'
              email:
                type:
                  - string
                  - 'null'
              source:
                type: string
                enum:
                  - person
                  - rule
                description: '`person`: added by hand. `rule`: added by an approval rule.'
              decision:
                type:
                  - string
                  - 'null'
                enum:
                  - approved
                  - rejected
                  - null
            required:
              - user_id
              - first_name
              - last_name
              - email
              - source
              - decision
          description: >-
            In the order they were added. Any one of them decides. Empty while
            pending means no one can approve the order yet: add someone with
            updatePurchaseOrderApprovers.
        approver_teams:
          type: array
          items:
            type: object
            properties:
              team_id:
                type:
                  - string
                  - 'null'
                format: uuid
                description: Null when the team has been deleted since.
              name:
                type:
                  - string
                  - 'null'
                description: Null when the team has been deleted since.
              source:
                type: string
                enum:
                  - person
                  - rule
                description: '`person`: added by hand. `rule`: added by an approval rule.'
              decision:
                type:
                  - string
                  - 'null'
                enum:
                  - approved
                  - rejected
                  - null
              decided_by:
                type:
                  - object
                  - 'null'
                properties:
                  user_id:
                    type: string
                    minLength: 1
                    maxLength: 200
                    pattern: ^[A-Za-z0-9_-]+$
                  first_name:
                    type:
                      - string
                      - 'null'
                  last_name:
                    type:
                      - string
                      - 'null'
                  email:
                    type:
                      - string
                      - 'null'
                required:
                  - user_id
                  - first_name
                  - last_name
                  - email
                description: Who decided for the team; null until someone has.
              nobody_can_act:
                type: boolean
                description: >-
                  Nobody in the team can approve the order now: no member has
                  write access and can see it. Add someone to the team, or add
                  another approver. False once the team has decided or the
                  request is not pending.
              members:
                type: array
                items:
                  type: object
                  properties:
                    user_id:
                      type: string
                      minLength: 1
                      maxLength: 200
                      pattern: ^[A-Za-z0-9_-]+$
                    first_name:
                      type:
                        - string
                        - 'null'
                    last_name:
                      type:
                        - string
                        - 'null'
                    email:
                      type:
                        - string
                        - 'null'
                  required:
                    - user_id
                    - first_name
                    - last_name
                    - email
                description: >-
                  Who is in the team now: any of them with write access who can
                  see the order may decide for it.
            required:
              - team_id
              - name
              - source
              - decision
              - decided_by
              - nobody_can_act
              - members
          description: >-
            Teams asked to approve, in the order they were added; each counts as
            one approver.
        skipped_approvers:
          type: array
          items:
            type: object
            properties:
              user_id:
                type: string
                minLength: 1
                maxLength: 200
                pattern: ^[A-Za-z0-9_-]+$
              first_name:
                type:
                  - string
                  - 'null'
              last_name:
                type:
                  - string
                  - 'null'
              email:
                type:
                  - string
                  - 'null'
              reason:
                type: string
                enum:
                  - no_access
                  - no_write
                  - removed_by_hand
                description: >-
                  `no_access`: their access limits hide the order. `no_write`:
                  role without write access. `removed_by_hand`: a person removed
                  them.
            required:
              - user_id
              - first_name
              - last_name
              - email
              - reason
          description: >-
            People an approval rule names but did not add, while the request is
            pending.
        skipped_teams:
          type: array
          items:
            type: object
            properties:
              team_id:
                type: string
                format: uuid
              name:
                type: string
            required:
              - team_id
              - name
          description: >-
            Teams an approval rule names but did not add because nobody in them
            could approve the order, while the request is pending.
        requested_at:
          type: string
          format: date-time
        decided_at:
          type:
            - string
            - 'null'
          format: date-time
        decided_by:
          type:
            - object
            - 'null'
          properties:
            user_id:
              type: string
              minLength: 1
              maxLength: 200
              pattern: ^[A-Za-z0-9_-]+$
            first_name:
              type:
                - string
                - 'null'
            last_name:
              type:
                - string
                - 'null'
            email:
              type:
                - string
                - 'null'
          required:
            - user_id
            - first_name
            - last_name
            - email
        rejection_reason:
          type:
            - string
            - 'null'
          description: Why the order was rejected; null when no reason was given.
      required:
        - id
        - status
        - sent
        - revision
        - proposal_id
        - approvers
        - approver_teams
        - skipped_approvers
        - skipped_teams
        - requested_at
        - decided_at
        - decided_by
        - rejection_reason
      description: >-
        The order's approval request. A draft's latest: pending, or its
        decision. Past a draft, the one deciding a proposed revision while one
        waits, else the one that approved the terms in force. Null when it
        needed none (opened without approval, or imported), or a draft's request
        was withdrawn.
    PurchaseOrderImportState:
      type:
        - object
        - 'null'
      properties:
        id:
          type: string
          format: uuid
        intent:
          type:
            - string
            - 'null'
          enum:
            - new
            - placed
            - null
        missing:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseOrderImportGap'
        printed:
          type: object
          properties:
            supplier:
              $ref: '#/components/schemas/PurchaseOrderPrintedParty'
            buyer:
              $ref: '#/components/schemas/PurchaseOrderPrintedParty'
          required:
            - supplier
            - buyer
          description: >-
            The supplier and buyer as the documents print them, to choose the
            right party on a draft. Null where the documents name none.
      required:
        - id
        - intent
        - missing
        - printed
      description: >-
        The import that drafted the order from documents: what they show
        (intent), what the draft still needs (missing) and the parties as
        printed. Null for an order created otherwise.
    PurchaseOrderProposedRevision:
      type:
        - object
        - 'null'
      properties:
        id:
          type: string
          format: uuid
          description: >-
            Send it as proposed_revision.id to accept or reject the proposed
            revision.
        revision:
          type:
            - integer
            - 'null'
          description: >-
            The revision it makes once accepted; null on a draft, whose
            supplier's reply proposes its lines.
        source:
          type: string
          enum:
            - member
            - supplier
          description: >-
            `member`: an edit that needs approval. `supplier`: read from a
            supplier's confirmation.
        decided_by:
          type: string
          enum:
            - approvers
            - members
          description: >-
            `approvers`: it needs approval, so the order's approval request
            decides it (approve or reject through approval). `members`: any
            member accepts or rejects it.
        prices_without_vat_basis:
          type: boolean
          description: >-
            The supplier's document stated no VAT basis, so its prices were read
            as excluding VAT. Check them before accepting.
        supplier_has_after_accept:
          type: boolean
          description: >-
            Accepting it leaves the supplier with the revision it makes: their
            own change to terms they had. Otherwise the order is sent to them
            afterwards.
        proposed_by:
          type:
            - object
            - 'null'
          properties:
            user_id:
              type: string
            first_name:
              type:
                - string
                - 'null'
            last_name:
              type:
                - string
                - 'null'
            email:
              type:
                - string
                - 'null'
          required:
            - user_id
            - first_name
            - last_name
            - email
          description: >-
            The person who proposed it; null for a confirmation read without
            one.
        document_ids:
          type: array
          items:
            type: string
            format: uuid
          description: The order's documents it was read from, attachments first.
        changes:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
              from:
                $ref: '#/components/schemas/ActivityValue'
              to:
                $ref: '#/components/schemas/ActivityValue'
            required:
              - field
              - from
              - to
            additionalProperties:
              $ref: '#/components/schemas/ActivityValue'
          description: >-
            Each changed term (`field`, `from`, `to`) and each added, changed or
            cancelled line (`field` line_items with `line_id`), as the order
            activity shows changes. Empty when it can no longer be shown against
            the order.
        currency_code:
          type:
            - string
            - 'null'
          description: >-
            The currency it gives the order, which `totals` are in; the order's
            own unless it changes it.
        totals:
          type: object
          properties:
            lines_excluding_vat:
              type: string
            commitment:
              type:
                - string
                - 'null'
          required:
            - lines_excluding_vat
            - commitment
        agreement_check:
          type:
            - object
            - 'null'
          properties:
            findings:
              type: array
              items:
                oneOf:
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - unit_price
                      target:
                        type: string
                      applicable:
                        type: boolean
                      line_key:
                        type: string
                      fingerprint:
                        type: string
                      evidence:
                        type: object
                        properties:
                          agreement_id:
                            type: string
                            format: uuid
                          price_item_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          document_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          terms:
                            type:
                              - string
                              - 'null'
                        required:
                          - agreement_id
                          - price_item_id
                          - document_id
                          - terms
                      current_unit_price:
                        type: string
                        pattern: ^-?\d+(?:\.\d+)?$
                      agreement_unit_price:
                        type: string
                        pattern: ^-?\d+(?:\.\d+)?$
                      quantity:
                        type: string
                        pattern: ^-?\d+(?:\.\d+)?$
                      amount_difference:
                        type: string
                        pattern: ^-?\d+(?:\.\d+)?$
                      unit_to_set:
                        type:
                          - string
                          - 'null'
                    required:
                      - code
                      - target
                      - applicable
                      - line_key
                      - fingerprint
                      - evidence
                      - current_unit_price
                      - agreement_unit_price
                      - quantity
                      - amount_difference
                      - unit_to_set
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - unit
                      target:
                        type: string
                      applicable:
                        type: boolean
                      line_key:
                        type: string
                      fingerprint:
                        type: string
                      evidence:
                        type: object
                        properties:
                          agreement_id:
                            type: string
                            format: uuid
                          price_item_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          document_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          terms:
                            type:
                              - string
                              - 'null'
                        required:
                          - agreement_id
                          - price_item_id
                          - document_id
                          - terms
                      current_unit:
                        type:
                          - string
                          - 'null'
                      agreement_unit:
                        type:
                          - string
                          - 'null'
                      current_unit_price:
                        type: string
                        pattern: ^-?\d+(?:\.\d+)?$
                      agreement_unit_price:
                        type:
                          - string
                          - 'null'
                        pattern: ^-?\d+(?:\.\d+)?$
                    required:
                      - code
                      - target
                      - applicable
                      - line_key
                      - fingerprint
                      - evidence
                      - current_unit
                      - agreement_unit
                      - current_unit_price
                      - agreement_unit_price
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - no_agreement_price
                      target:
                        type: string
                      applicable:
                        type: boolean
                      line_key:
                        type: string
                      fingerprint:
                        type: string
                    required:
                      - code
                      - target
                      - applicable
                      - line_key
                      - fingerprint
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - uncertain
                      target:
                        type: string
                      applicable:
                        type: boolean
                      line_key:
                        type: string
                      fingerprint:
                        type: string
                      evidence:
                        type: object
                        properties:
                          agreement_id:
                            type: string
                            format: uuid
                          price_item_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          document_id:
                            type:
                              - string
                              - 'null'
                            format: uuid
                          terms:
                            type:
                              - string
                              - 'null'
                        required:
                          - agreement_id
                          - price_item_id
                          - document_id
                          - terms
                      reason:
                        type: string
                        enum:
                          - calculation_rules
                          - rate_price
                          - ambiguous_price
                          - no_valid_price
                          - currency_mismatch
                          - no_order_currency
                      price_item_ids:
                        type: array
                        items:
                          type: string
                          format: uuid
                    required:
                      - code
                      - target
                      - applicable
                      - line_key
                      - fingerprint
                      - evidence
                      - reason
                      - price_item_ids
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - supplier
                      target:
                        type: string
                      applicable:
                        type: boolean
                      fingerprint:
                        type: string
                      supplier_id:
                        type: string
                        format: uuid
                    required:
                      - code
                      - target
                      - applicable
                      - fingerprint
                      - supplier_id
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - buyer
                      target:
                        type: string
                      applicable:
                        type: boolean
                      fingerprint:
                        type: string
                      buyer_id:
                        type: string
                        format: uuid
                    required:
                      - code
                      - target
                      - applicable
                      - fingerprint
                      - buyer_id
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - term
                      target:
                        type: string
                      applicable:
                        type: boolean
                      fingerprint:
                        type: string
                      fields:
                        type: array
                        items:
                          type: string
                          enum:
                            - issued_date
                            - valid_from
                            - valid_until
                        minItems: 1
                      effective_date:
                        type:
                          - string
                          - 'null'
                      expiration_date:
                        type:
                          - string
                          - 'null'
                    required:
                      - code
                      - target
                      - applicable
                      - fingerprint
                      - fields
                      - effective_date
                      - expiration_date
            lines:
              type: array
              items:
                type: object
                properties:
                  key:
                    type: string
                    description: The `line_id` of its line_items change.
                  outcome:
                    type: string
                    enum:
                      - no_difference
                      - differs
                      - not_checked
                  price_item_id:
                    type:
                      - string
                      - 'null'
                    format: uuid
                  agreement_unit_price:
                    type:
                      - string
                      - 'null'
                  copied_from_agreement:
                    type: boolean
                  price_fingerprint:
                    type:
                      - string
                      - 'null'
                  terms:
                    type:
                      - string
                      - 'null'
                required:
                  - key
                  - outcome
                  - price_item_id
                  - agreement_unit_price
                  - copied_from_agreement
                  - price_fingerprint
                  - terms
          required:
            - findings
            - lines
          description: >-
            The proposed lines checked against the order's agreement, as
            getPurchaseOrderAgreementCheck checks the order's own; its findings
            cannot be applied. Null when the order has no agreement the caller
            can see.
        created_at:
          type: string
          format: date-time
      required:
        - id
        - revision
        - source
        - decided_by
        - prices_without_vat_basis
        - supplier_has_after_accept
        - proposed_by
        - document_ids
        - changes
        - currency_code
        - totals
        - agreement_check
        - created_at
      description: >-
        A change to the order's terms waiting for a decision: an edit that needs
        approval, or what a supplier's confirmation prints differently. The
        order keeps its current revision, which is what is sent and pushed,
        until it is accepted; its terms cannot change meanwhile. Null when none
        waits.
    PurchaseOrderSupplierReply:
      type: object
      properties:
        request:
          type:
            - object
            - 'null'
          properties:
            kind:
              type: string
              enum:
                - order
                - price_request
              description: 'order: the order was sent. price_request: a price was asked for.'
            sent_at:
              type: string
              format: date-time
              description: When it went out, or may have.
            sent_to:
              type: array
              items:
                type: string
              description: Its To addresses.
            replied_at:
              type:
                - string
                - 'null'
              format: date-time
              description: >-
                When the supplier's latest email after it arrived, at the reply
                address or forwarded by a member; null while it waits for an
                answer.
          required:
            - kind
            - sent_at
            - sent_to
            - replied_at
          description: >-
            The latest email that asked the supplier for something: the order,
            or a price. Messages ask for nothing, so they are not one. Null when
            none went out.
        confirmed_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When the supplier confirmed the order's current terms: their
            confirmation matched them, or the changes it proposed were accepted.
            A member's change to the terms clears it; a later delivery notice or
            message does not. A draft they confirmed only needs opening.
      required:
        - request
        - confirmed_at
      description: >-
        What the order waits for from its supplier, and whether they confirmed
        it. Derived from the emails sent and the supplier's documents received.
    PurchaseOrderImportGap:
      type: object
      properties:
        field:
          type: string
          enum:
            - supplier
            - buyer
            - currency
            - lines
            - quantity
            - unit_price
            - price_basis
            - total
            - delivery_date
            - delivery
            - other
            - sources
          description: >-
            What the draft still needs. supplier, buyer, currency and lines
            follow the order as it is now, as does unit_price: a line whose
            price the documents left out and that is still zero. The others are
            notes from reading the documents, shown while the order is a draft:
            quantity, price_basis (VAT), total (the lines differ from the
            printed total by more than 1), delivery_date, delivery, sources
            (files not read in full: past the reading limit, too large, an email
            that cannot be parsed, an attachment left out, or text read in part
            as "name (read / total characters)"; named in note) and other.
        line_id:
          type:
            - string
            - 'null'
          format: uuid
          description: The line it concerns; null for the order.
        note:
          type:
            - string
            - 'null'
          description: >-
            What the documents showed, in the organization language; null when
            the field says it all.
      required:
        - field
        - line_id
        - note
    PurchaseOrderPrintedParty:
      type:
        - object
        - 'null'
      properties:
        name:
          type:
            - string
            - 'null'
        organization_number:
          type:
            - string
            - 'null'
        vat_number:
          type:
            - string
            - 'null'
      required:
        - name
        - organization_number
        - vat_number
    ActivityValue:
      type:
        - string
        - number
        - boolean
        - 'null'
        - array
        - object
      items:
        $ref: '#/components/schemas/ActivityValue'
      additionalProperties:
        $ref: '#/components/schemas/ActivityValue'
  securitySchemes:
    ApiKeyBearer:
      type: http
      scheme: bearer
      description: >-
        Personal API key sent as a bearer token, together with
        X-Organization-Id. The key must have at least the access level the
        endpoint requires (read, write or admin).

````

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