> ## 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 the approval policy

> Saves the given parts of the approval policy; omitted fields are unchanged. Applies to invoices evaluated from then on. A changed settings.required_approvals also approves pending invoices that already have that many approvals. Every invoice is evaluated once its checks and coding have settled, and the result is shown on the invoice as approval_evaluation. The trust conditions always apply; the amount limit is set in settings. With automatic rejection on, an invoice read with confidence whose payment terms are too short is rejected by Watchdog. With automatic approval on, a trusted invoice that is the same as the supplier's last invoices is approved by Watchdog. Rejection runs first.



## OpenAPI

````yaml /openapi.json patch /v1/approval-policy
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/approval-policy:
    patch:
      tags:
        - Approval policy
        - Invoices
        - Settings
      summary: Update the approval policy
      description: >-
        Saves the given parts of the approval policy; omitted fields are
        unchanged. Applies to invoices evaluated from then on. A changed
        settings.required_approvals also approves pending invoices that already
        have that many approvals. Every invoice is evaluated once its checks and
        coding have settled, and the result is shown on the invoice as
        approval_evaluation. The trust conditions always apply; the amount limit
        is set in settings. With automatic rejection on, an invoice read with
        confidence whose payment terms are too short is rejected by Watchdog.
        With automatic approval on, a trusted invoice that is the same as the
        supplier's last invoices is approved by Watchdog. Rejection runs first.
      operationId: updateApprovalPolicy
      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.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateApprovalPolicy'
      responses:
        '200':
          description: The saved policy.
          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/ApprovalPolicy'
        '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
        '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:
    UpdateApprovalPolicy:
      type: object
      properties:
        auto_approve_enabled:
          type: boolean
          description: Turns automatic approval on or off.
        settings:
          type: object
          properties:
            max_amount:
              type:
                - string
                - 'null'
              pattern: ^\d{1,18}(\.\d{1,2})?$
              description: >-
                The highest total including VAT, in the organization's currency,
                an invoice may have to be trusted, as a decimal string with up
                to two decimals. Null for no limit.
            required_approvals:
              type: integer
              minimum: 1
              maximum: 50
              description: >-
                How many of an invoice's approvers must approve it. An approver
                who disagrees sends it back, and an admin's own approval decides
                it. 1 by default.
            single_rule:
              type: boolean
              description: >-
                Whether an invoice's approvers come from one approval rule: the
                first in the rules' order that matches it. Off by default: every
                matching rule adds its approvers. Applies to invoices that get
                approvers from then on.
            same_as_always:
              type: object
              properties:
                enabled:
                  type: boolean
                  description: Whether the reason counts.
                amount_tolerance_pct:
                  type: integer
                  minimum: 0
                  maximum: 100
                  description: >-
                    How many percent the total may differ from each earlier
                    invoice.
                history_count:
                  type: integer
                  minimum: 1
                  maximum: 12
                  description: >-
                    How many of the supplier's last invoices the invoice is
                    compared with.
              additionalProperties: false
          additionalProperties: false
          description: Omitted settings are unchanged.
      additionalProperties: false
    ApprovalPolicy:
      type: object
      properties:
        auto_approve_enabled:
          type: boolean
          description: >-
            Whether invoices are approved automatically when every trust and
            limit condition passes and at least one reason holds, such as
            same_as_always.
        settings:
          $ref: '#/components/schemas/ApprovalPolicySettings'
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/ApprovalPolicyCondition'
          description: >-
            Every condition an invoice is evaluated against, in the order they
            are shown.
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the policy was last saved; null while it has its defaults.
      required:
        - auto_approve_enabled
        - settings
        - conditions
        - updated_at
    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_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
    ApprovalPolicySettings:
      type: object
      properties:
        max_amount:
          type:
            - string
            - 'null'
          pattern: ^\d{1,18}(\.\d{1,2})?$
          description: >-
            The highest total including VAT, in the organization's currency, an
            invoice may have to be trusted, as a decimal string with up to two
            decimals. Null for no limit.
        required_approvals:
          type: integer
          minimum: 1
          maximum: 50
          description: >-
            How many of an invoice's approvers must approve it. An approver who
            disagrees sends it back, and an admin's own approval decides it. 1
            by default.
        single_rule:
          type: boolean
          description: >-
            Whether an invoice's approvers come from one approval rule: the
            first in the rules' order that matches it. Off by default: every
            matching rule adds its approvers. Applies to invoices that get
            approvers from then on.
        same_as_always:
          $ref: '#/components/schemas/ApprovalPolicySameAsAlways'
      required:
        - max_amount
        - required_approvals
        - single_rule
        - same_as_always
    ApprovalPolicyCondition:
      type: object
      properties:
        key:
          type: string
          description: >-
            The condition, for example read_with_confidence or
            amount_under_limit.
        kind:
          type: string
          enum:
            - trust
            - limit
            - reason
          description: >-
            `trust`: always required, so it cannot be turned off. `limit`: set
            in settings. `reason`: a reason to approve automatically, which
            holds when its condition passes.
        locked:
          type: boolean
          description: True when the condition is always required.
      required:
        - key
        - kind
        - locked
    ApprovalPolicySameAsAlways:
      type: object
      properties:
        enabled:
          type: boolean
          description: Whether the reason counts.
        amount_tolerance_pct:
          type: integer
          minimum: 0
          maximum: 100
          description: How many percent the total may differ from each earlier invoice.
        history_count:
          type: integer
          minimum: 1
          maximum: 12
          description: >-
            How many of the supplier's last invoices the invoice is compared
            with.
      required:
        - enabled
        - amount_tolerance_pct
        - history_count
      description: >-
        The approve reason "same invoice as always": the invoice has the same
        lines (description and quantity) as each of the supplier's last
        history_count invoices, and a total within amount_tolerance_pct percent
        of each. Fewer earlier invoices never match.
  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.