openapi: 3.0.1
info:
  description: Accountflow's public API for external integrations.
  title: Accountflow Bridge API
  version: 1.0.0
servers:
- url: https://api.prod.accountflow.com
  description: prod
security:
- oauth2: []
tags:
- description: Exchange your API client's credentials for a bearer token. Every other
    endpoint requires one.
  name: Authentication
- description: Named groups of an organization's companies
  name: Portfolios
- description: "Bank accounts, transactions, and bank↔GL reconciliation"
  name: Bank & Reconciliation
- description: VAT filing terms and their status
  name: VAT
- description: The chart of accounts mapped to the country's standard accounts
  name: Account mapping
- description: "One account's own settings (reconciliation, owners, automation), read\
    \ and patched by settingsRevision"
  name: Account settings
- description: Comments and flags on reconciliation subjects
  name: Collaboration
- description: "Who did what, when: an organization's audit trail"
  name: Audit log
- description: "Month-close status: reconciliation, approvals, work queue and blockers"
  name: Close
- description: "A company's modules, currency, responsible people and automation"
  name: Company settings
- description: Regulatory deadlines and ERP data freshness
  name: Company status
- description: Order automatic reconciliation for accounts and follow the runs
  name: Reconciliation runs
- description: "Chart of accounts, GL lines, and trial balances"
  name: General Ledger
- description: "Signed event notifications — poke, then fetch"
  name: Webhooks
- description: The organizations within your reach
  name: Organizations
- description: "An account's opening balances, accruals, reconciliation adjustments\
    \ and activity history"
  name: Account detail
- description: "Push ledger data into a company that is managed through the API, and\
    \ follow each import to its outcome. Every import runs asynchronously: the request\
    \ is validated, accepted with 202, and executed by a job whose result lands on\
    \ the import. Push in this order: accounts, then dimensions and sub-ledgers (optional),\
    \ opening balances, general-ledger lines, open items. One import per kind and\
    \ company runs at a time."
  name: Imports
- description: "Intercompany groups and counterparty links: their reconciliation lines\
    \ and accounts"
  name: Intercompany
- description: "The routines that apply to an account: the company's own, and the\
    \ organization's and portfolios' switched on or off"
  name: Routines
- description: Settlements (utligninger) of general-ledger lines on an account
  name: Settlements
- description: "System-generated tasks: what the rules found to fix, per company and\
    \ account"
  name: Tasks
- description: "The company's account template: choose it, preview and apply it, see\
    \ and restore what it set"
  name: Account templates
- description: Document metadata; binaries via signed URLs
  name: Documents
- description: The company's contact people and their roles
  name: Contacts
- description: "Customer and supplier open items, aging, and sub-ledger reconciliation"
  name: Sub-ledgers
- description: The accounting clients (companies) within your reach
  name: Companies
- description: The organization's users
  name: Users
- description: Access policies and their user assignments
  name: Access Management
- description: "Asynchronous work: submit via a resource endpoint, poll here"
  name: Jobs
- description: Verify your integration's credentials and scope
  name: Identity
paths:
  /protocol/openid-connect/token:
    post:
      description: |-
        Exchanges an API client's `client_id` and `client_secret` for a short-lived bearer token, using the OAuth 2.0 client-credentials grant. Send the token as `Authorization: Bearer <access_token>` on every other request.

        Create a client under organization settings → integrations; the secret is shown once, at creation. Tokens are short-lived — fetch one per session or when the previous one expires, not per request. What the token is allowed to do comes from the scopes granted to the client, not from anything in this request.

        This endpoint lives on the authorization server, so its errors follow OAuth 2.0 (RFC 6749) rather than the problem documents the rest of this API returns.
      operationId: createAccessToken
      requestBody:
        content:
          application/x-www-form-urlencoded:
            examples:
              clientCredentials:
                value:
                  client_id: com.accountflow.api.prod.4be9a1c803f2
                  client_secret: your-client-secret
                  grant_type: client_credentials
            schema:
              type: object
              properties:
                client_id:
                  type: string
                  description: The API client's id.
                client_secret:
                  type: string
                  description: The secret shown once when the client was created.
                grant_type:
                  type: string
                  description: Always `client_credentials`.
                  enum:
                  - client_credentials
              required:
              - client_id
              - client_secret
              - grant_type
        required: true
      responses:
        "200":
          content:
            application/json:
              examples:
                token:
                  value:
                    access_token: eyJhbGciOiJSUzI1NiIsInR5cCI6ImF0K2p3dCJ9…
                    expires_in: 300
                    scope: ledger:read companies:read
                    token_type: Bearer
              schema:
                type: object
                properties:
                  access_token:
                    type: string
                    description: The bearer token. Send it in the Authorization header.
                  expires_in:
                    type: integer
                    description: Lifetime in seconds.
                  scope:
                    type: string
                    description: "Informational. For API clients the scopes that apply\
                      \ are the ones granted when the client was provisioned (see\
                      \ GET /v1/whoami), not this claim; it is authoritative only\
                      \ for interactive (MCP) sessions."
                  token_type:
                    type: string
                    description: Always `Bearer`.
          description: A bearer token.
        "401":
          content:
            application/json:
              examples:
                invalidClient:
                  value:
                    error: invalid_client
                    error_description: Invalid client or Invalid client credentials
              schema:
                type: object
                description: OAuth 2.0 error (RFC 6749) — not this API's problem-document
                  shape.
                properties:
                  error:
                    type: string
                    description: "Machine-readable code, e.g. `invalid_client`."
                  error_description:
                    type: string
          description: "The client id or secret is wrong, or the client is disabled."
      security: []
      summary: Get an access token
      tags:
      - Authentication
    servers:
    - description: Authorization server
      url: https://auth.prod.accountflow.com/realms/accountflow
  /v1/companies:
    get:
      description: Cursor-paginated list of the companies you can read. Iterate with
        pagination.nextCursor while pagination.hasMore; cursors are bound to your
        credentials and this endpoint's filters.
      operationId: listCompanies
      parameters:
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageCompanyResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:read
      summary: List companies
      tags:
      - Companies
  /v1/companies/{companyId}:
    delete:
      description: "Soft delete: the company disappears from the API (404) and can\
        \ be restored with POST /actions/restore. Idempotent."
      operationId: deleteCompany
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      - description: "Optional free-text reason, recorded in the audit trail (max\
          \ 200 characters)."
        in: query
        name: reason
        required: false
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeletionResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:write
      summary: Delete a company
      tags:
      - Companies
    get:
      operationId: getCompany
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:read
      summary: Get a company
      tags:
      - Companies
    patch:
      description: "Patch semantics: absent fields stay unchanged. The fiscal year's\
        \ start month is not changed here: a request naming another month than the\
        \ company's is refused with 422 and changes nothing."
      operationId: updateCompany
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCompanyRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:write
      summary: Update a company
      tags:
      - Companies
  /v1/companies/{companyId}/access:
    get:
      description: |-
        Every person who reaches the company, highest role first: the role, the role on every account (`unrestrictedRole`, null when every grant is restricted), the template and account grants above it, and every source — each policy rule, assigned directly or to a group, with a time-bound grant's `validFrom`/`validTo`, or `ORG_ADMIN` — with the decisive one flagged. One page: the company's whole list.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listCompanyAccess
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageCompanyAccessResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'access:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: access:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - access:manage
      summary: List who has access to one company
      tags:
      - Access Management
  /v1/companies/{companyId}/account-activity:
    get:
      description: "The account's History tab: user-visible events recorded against\
        \ the account, newest first, cursor-paginated. Actor e-mail, IP address and\
        \ user agent are never included. A caller whose access is limited to other\
        \ accounts of the company gets 404."
      operationId: getAccountActivity
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: The account id; wins over accountNumber.
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: The accounting year accountNumber is resolved in; default the
          current one.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageAccountActivityResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Get an account's activity history
      tags:
      - Account detail
  /v1/companies/{companyId}/account-mappings:
    post:
      description: Rows that cannot be mapped are reported and the rest are mapped;
        a database failure maps none.
      operationId: mapAccounts
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MapAccountsRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BulkAccountMapping"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    detail: The account changed since it was read; read it again and
                      retry with the new settingsRevision.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Map many accounts to standard accounts
      tags:
      - Account mapping
  /v1/companies/{companyId}/account-status:
    get:
      description: "Every account's reconciliation status for one period: balance,\
        \ reconciled amount, deviation, status, approval, staleness, comments flag\
        \ and posts coverage. Accounts report on their own cadence. Ordered by account\
        \ number, cursor-paginated."
      operationId: listAccountStatus
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: MONTHLY (default) | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY
          | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: Only this account number.
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: Only this account (by id); wins over accountNumber.
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Only accounts in this status.
        in: query
        name: status
        required: false
        schema:
          type: string
          enum:
          - UNRECONCILED
          - APPROVED
          - RECONCILED
          - DEVIATION
          - AWAITING_CONTROL
          - STALE
          - READY_FOR_APPROVAL
          - OPEN
          - FUTURE
          - NOT_APPLICABLE
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageAccountStatusResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List account reconciliation status
      tags:
      - Close
  /v1/companies/{companyId}/account-template:
    get:
      description: "The template in use (the company's choice, else the organization's\
        \ default) and the organization's templates."
      operationId: getCompanyAccountTemplate
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyAccountTemplate"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: Get the company's account template
      tags:
      - Account templates
    patch:
      description: "A patch: accountTemplateId chooses a template, reset: [\"accountTemplateId\"\
        ] follows the organization's default again, and a body naming neither (only\
        \ expectedVersion, or {}) changes nothing. Changes no account: the template's\
        \ values reach the accounts when it is applied."
      operationId: chooseCompanyAccountTemplate
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ChooseAccountTemplateRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyAccountTemplate"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Choose the company's account template
      tags:
      - Account templates
  /v1/companies/{companyId}/account-template/actions/apply:
    post:
      description: "Overwrites the covered accounts' values, the company's own changes\
        \ included, and makes the company follow the template. 409 when the template\
        \ changed since the preview; 422 with `warnings` when a warning is not confirmed."
      operationId: applyCompanyAccountTemplate
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ApplyAccountTemplateRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountTemplateApplied"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    detail: The template changed since the preview. Review the preview
                      again.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                confirmation_required:
                  value:
                    detail: "These changes must be confirmed: [AUTO_APPROVE_ENABLED]"
                    error: unprocessable
                    reason: confirmation_required
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Unprocessable
                    type: https://api.accountflow.com/errors/unprocessable
                    warnings:
                    - AUTO_APPROVE_ENABLED
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Apply the company's account template to its accounts
      tags:
      - Account templates
  /v1/companies/{companyId}/account-template/preview:
    get:
      description: "Each mapped account the template would change, value by value,\
        \ the entry revisions to pass to apply, and the warnings to confirm. Changes\
        \ nothing."
      operationId: previewCompanyAccountTemplate
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountTemplateApplyPreview"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                no_template:
                  value:
                    detail: The organization has no account template
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not. `reason`\
            \ and the extensions say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: Preview applying the company's account template
      tags:
      - Account templates
  /v1/companies/{companyId}/accounts:
    get:
      description: "The company's accounts for one accounting year, cursor-paginated\
        \ by account number. Omit `year` for the current accounting year. Accounts\
        \ are identified by their account number, which is stable across years. `accountId`\
        \ is one accounting year's account — every year has a new one — so `accountNumber`\
        \ + `year` is the stable key; send `accountId` where an operation takes it,\
        \ for example the bulk account mapping and the account settings."
      operationId: listAccounts
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageLedgerAccountResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List the chart of accounts
      tags:
      - General Ledger
  /v1/companies/{companyId}/accounts/{accountNumber}:
    delete:
      description: "Delete one account from the chart of one accounting year (the\
        \ current one when year is omitted). Only an unused account can go (409 account_in_use\
        \ otherwise); to retire an account that has history, import it with hidden:\
        \ true. All or nothing: if anything requested is in use, the answer is 409\
        \ with reason and an inUse list of ids and what depends on each, and nothing\
        \ is deleted. Returns 202 with the import to poll; one import or correction\
        \ per kind and company runs at a time."
      operationId: deleteAccount
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The accounting year whose chart the account is deleted from.\
          \ Omitted = the company's current accounting year, which around year end\
          \ may already be the new one: send year."
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                account_in_use:
                  value:
                    detail: "1 account is in use and nothing was deleted: remove the\
                      \ dependent work in the application first, or post a reversing\
                      \ line instead"
                    error: conflict
                    inUse:
                    - dependencies:
                      - reconciliation
                      id: INV-2025-000123-1
                    reason: account_in_use
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.accounts' job is already in flight for this
                      scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Delete an unused account
      tags:
      - Imports
    get:
      description: "One account of the chart, addressed by its account number. Omit\
        \ `year` for the current accounting year. The answer carries that year's `accountId`."
      operationId: getAccount
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 3000
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerAccountResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: Get one account
      tags:
      - General Ledger
  /v1/companies/{companyId}/accounts/{accountNumber}/mapping:
    delete:
      description: "Its template, documentation requirement and rules stay as they\
        \ are."
      operationId: unmapAccount
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: The settingsRevision a read returned; refused with 409 if it
          moved on.
        in: query
        name: settingsRevision
        required: true
        schema:
          type: integer
          format: int64
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountMapping"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    detail: The account changed since it was read; read it again and
                      retry with the new settingsRevision.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Take an account off its standard account
      tags:
      - Account mapping
    patch:
      description: "A standard account of the company's country. A template-managed\
        \ company's account takes the template's values for it, except those the company\
        \ changed itself."
      operationId: mapAccount
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MapAccountRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountMapping"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    detail: The account changed since it was read; read it again and
                      retry with the new settingsRevision.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Map an account to a standard account
      tags:
      - Account mapping
  /v1/companies/{companyId}/accounts/{accountNumber}/reconciliation:
    get:
      description: "One account and period: balance vs reconciled amount, deviation,\
        \ status, the standing approval and its coverage, adjustment lines, comment\
        \ count, and approval readiness."
      operationId: getAccountReconciliation
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: The account's id; must name the same account when given.
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: MONTHLY (default) | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY
          | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountReconciliationResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Get one account's reconciliation
      tags:
      - Close
  /v1/companies/{companyId}/accounts/{accountNumber}/routine:
    delete:
      description: The organization's and portfolios' routines apply as before; the
        history is kept.
      operationId: deleteAccountRoutine
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; the current one when absent.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: companyRoutineVersion from the routines read; refused with 409
          if the company's routine changed since.
        in: query
        name: expectedVersion
        required: false
        schema:
          type: string
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RoutineSourcesResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Remove the company's own routine from an account
      tags:
      - Routines
    post:
      description: "Creates it, or replaces the one the company has."
      operationId: setAccountRoutine
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; the current one when absent.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SetAccountRoutineRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RoutineSourcesResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Write the company's own routine on an account
      tags:
      - Routines
  /v1/companies/{companyId}/accounts/{accountNumber}/routines:
    get:
      description: "The organization's and portfolios' routines that apply, with whether\
        \ each is switched on for the account, and the company's own routine."
      operationId: getAccountRoutines
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; the current one when absent.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: Include earlier versions.
        in: query
        name: includeHistory
        required: false
        schema:
          type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RoutineSourcesResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: Get one account's routines
      tags:
      - Routines
  /v1/companies/{companyId}/accounts/{accountNumber}/routines/{routineId}:
    patch:
      description: An organization's or portfolio's routine that applies to the account.
      operationId: setRoutineSourceActive
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - in: path
        name: routineId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year; the current one when absent.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SetRoutineSourceActiveRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RoutineSourcesResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Switch a routine on or off for an account
      tags:
      - Routines
  /v1/companies/{companyId}/accounts/{accountNumber}/settings:
    get:
      description: "Owner, documentation requirement, hidden, match window and the\
        \ account's own automatic reconciliation values, with the settingsRevision\
        \ to change them."
      operationId: getAccountSettings
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; the current one when absent.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountSettings"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: Get one account's settings
      tags:
      - Account settings
    patch:
      description: "Patch semantics: absent fields stay as they are; fields in reset\
        \ are cleared or inherit again. Refused with 409 when settingsRevision is\
        \ not the account's current one."
      operationId: updateAccountSettings
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; the current one when absent.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateAccountSettingsRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountSettings"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentRevision: 43
                    detail: The account changed since it was read; read it again and
                      retry with the new settingsRevision.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Change one account's settings
      tags:
      - Account settings
  /v1/companies/{companyId}/accounts/{accountNumber}/settings/actions/clear-automation-overrides:
    post:
      description: Removes the account's own automation values and match window and
        switches overrideCompanyDefaults off.
      operationId: clearAccountAutomationOverrides
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; the current one when absent.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ClearAutomationOverridesRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountSettings"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentRevision: 43
                    detail: The account changed since it was read; read it again and
                      retry with the new settingsRevision.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Return an account to the automation defaults
      tags:
      - Account settings
  /v1/companies/{companyId}/accounts/{accountNumber}/template-provenance:
    get:
      description: "The template entry, which values the company changed since, and\
        \ the template's values."
      operationId: getAccountTemplateProvenance
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountTemplateProvenance"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: Where an account's settings came from
      tags:
      - Account templates
  /v1/companies/{companyId}/accounts/{accountNumber}/template-provenance/actions/restore:
    post:
      description: Replaces the company's own value with the account template's current
        one.
      operationId: restoreAccountTemplateValue
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: path
        name: accountNumber
        required: true
        schema:
          type: string
      - description: "The account's id: one accounting year's account, as list_accounts\
          \ returns it. It names that year's account: the path's accountNumber must\
          \ be its number, and a year, when given, its accounting year (400 account_year_mismatch\
          \ otherwise)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RestoreTemplateValueRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountTemplateProvenance"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    detail: The account's template entry no longer exists
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Use the template's value for one of an account's settings
      tags:
      - Account templates
  /v1/companies/{companyId}/accrual-suggestions:
    get:
      description: "Ordered by account, then score (highest first), amount (largest\
        \ first) and key. Each carries the exact schedule accepting it would create.\
        \ Cursor-paginated when you send cursor or pageSize; a request with neither\
        \ returns every pending suggestion in one page (hasMore false), as it always\
        \ has. Follow nextCursor."
      operationId: listAccrualSuggestions
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Only this accruals account.
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageAccrualSuggestionResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List pending accrual suggestions
      tags:
      - General Ledger
  /v1/companies/{companyId}/accruals:
    get:
      description: |-
        Accruals (periodiseringer) on an ACCRUALS account that touch the period, with their recognition schedule and linked lines. `periodType` defaults to the account's reconciliation frequency; `cumulative=true` lists the year to date. Empty for accounts that are not ACCRUALS accounts.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listAccruals
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1740
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: The account id; wins over accountNumber.
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Cadence of period: MONTHLY, BIMONTHLY, QUARTERLY, TERTIARY,\
          \ HALF_YEARLY or YEARLY; default the account's reconciliation frequency."
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: Everything from the start of the year up to the period instead
          of the period alone (default false).
        in: query
        name: cumulative
        required: false
        schema:
          type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageAccountAccrualResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List the accruals on an account for a period
      tags:
      - Account detail
  /v1/companies/{companyId}/actions/disable:
    post:
      description: "Pauses the client: it stays readable with status DISABLED. Idempotent."
      operationId: disableCompany
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:write
      summary: Disable a company
      tags:
      - Companies
  /v1/companies/{companyId}/actions/enable:
    post:
      description: Idempotent.
      operationId: enableCompany
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:write
      summary: Enable a company
      tags:
      - Companies
  /v1/companies/{companyId}/actions/restore:
    post:
      description: Brings a soft-deleted company back in its prior state (ACTIVE or
        DISABLED). Refused (409) when the deletion was part of an organization cascade.
      operationId: restoreCompany
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:write
      summary: Restore a deleted company
      tags:
      - Companies
  /v1/companies/{companyId}/approvals:
    get:
      description: "Reconciliation approvals of the company's accounts, newest first,\
        \ revoked ones and re-approvals included. Cursor-paginated."
      operationId: listApprovals
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Only this account number (all years).
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: Only this account (by id).
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Only approvals of this accounting year; omitted = every year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY. With year: only approvals whose range\
          \ overlaps it."
        in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      - description: MONTHLY (default) | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY
          | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: APPROVED (standing) or REVOKED; omitted = both.
        in: query
        name: status
        required: false
        schema:
          type: string
          enum:
          - APPROVED
          - REVOKED
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageApprovalResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List account approvals
      tags:
      - Close
  /v1/companies/{companyId}/bank/accounts:
    get:
      description: "Always one page today (`hasMore` false, `nextCursor` null), but\
        \ follow `hasMore`: this list may page in a later release, and a client that\
        \ stops at the first page will then miss rows."
      operationId: listBankAccounts
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageBankAccount"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'bank:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: bank:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - bank:read
      summary: List the company's bank accounts
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/bank/accounts/{bankAccountId}/gl-lines:
    get:
      description: "The general-ledger lines of the GL account the bank account is\
        \ mapped to, for one accounting year, cursor-paginated by month. reconciliationStatus=UNRECONCILED\
        \ is the unmatched GL side. A bank account with no GL mapping is 400 with\
        \ reason bank_account_not_reconcilable."
      operationId: listBankGlLines
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: bankAccountId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year (required).
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      - description: "Month of the accounting year, 1-12: the calendar month when\
          \ the year starts in January. Only that month's lines."
        in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      - description: "Only lines in this bank reconciliation state: UNRECONCILED (in\
          \ no group: the unmatched GL side), RECONCILED, STALE, CORRECTION or MANUAL_CORRECTION\
          \ (recomputed on every read; any case is accepted)."
        in: query
        name: reconciliationStatus
        required: false
        schema:
          type: string
          enum:
          - UNRECONCILED
          - RECONCILED
          - STALE
          - CORRECTION
          - MANUAL_CORRECTION
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageBankGlLine"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                bank_account_not_reconcilable:
                  value:
                    detail: "The bank account feeds no GL account, so it has no GL\
                      \ lines to show"
                    error: validation_failed
                    reason: bank_account_not_reconcilable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: "List the GL lines of a bank account's GL account, with their reconciliation\
        \ state"
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/bank/accounts/{bankAccountId}/opening-balance:
    get:
      description: "The bank's booked balance walked back over everything booked since\
        \ the accounting year began (or a person's override), compared with the ledger's\
        \ opening balance on the GL account the bank account fed on the year's first\
        \ day, with the other bank accounts feeding it then summed in. status is MATCHED\
        \ (within tolerance), DEVIATION or UNAVAILABLE, with unavailableReasonCode\
        \ saying why. Recomputed on every read."
      operationId: getBankOpeningBalance
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: bankAccountId
        required: true
        schema:
          type: string
          format: uuid
      - description: "The accounting year whose opening balance to check (required;\
          \ 1900-2100). The year starts on its own fiscal-year start, 1 January for\
          \ most companies."
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BankOpeningBalance"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: "Get a bank account's opening balance, checked against the GL account"
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/bank/accounts/{bankAccountId}/reconciliation-summary:
    get:
      description: "Twelve periods with group/entry counts, staleness, and the firm's\
        \ period-approval status on the mapped GL account. Pass accountPeriod for\
        \ the approval figures: then periods holds only the month that account period\
        \ ends in, with its approvalFigures; without accountPeriod, approvalFigures\
        \ is null on every month."
      operationId: getReconciliationSummary
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: bankAccountId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year (required; there is no default).
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      - description: "The bank account's GL account period to compute the approval\
          \ figures for, in the GL account's own period type, in year: the month on\
          \ a monthly account, the quarter (1-4) on a quarterly one, and so on (approvalFigures.accountPeriod\
          \ in the response). With it, periods holds only the month that account period\
          \ ends in, with its approvalFigures; without it, every month and no approvalFigures.\
          \ 400 account_period_out_of_range when the GL account has no such period;\
          \ 400 bank_account_not_reconcilable when the bank account has no GL mapping\
          \ or its GL account no BANK template in the year."
        in: query
        name: accountPeriod
        required: false
        schema:
          type: integer
          format: int32
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReconciliationSummary"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Per-period reconciliation summary
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/bank/accounts/{bankAccountId}/reconciliations:
    get:
      description: "The groups that concern the bank account (created on it, or holding\
        \ one of its transactions), ordered by accounting year, period and id, each\
        \ with its entries. Cursor-paginated when you send year, cursor or pageSize.\
        \ A request with none of the three returns every group of every year in one\
        \ page (hasMore false), as it always has; that request will default to the\
        \ current accounting year in a later release, so send year (and period) and\
        \ follow nextCursor."
      operationId: listReconciliations
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: bankAccountId
        required: true
        schema:
          type: string
          format: uuid
      - description: The accounting year the groups are attributed to (their year).
          Omitted = every year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Month of the accounting year, 1-12: the calendar month when\
          \ the year starts in January. Only the groups of that month, in every year\
          \ unless year is given."
        in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageReconciliation"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List reconciliation groups for a bank account
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/bank/accounts/{bankAccountId}/statement-batches:
    get:
      description: "The statement files people uploaded to a MANUAL bank account,\
        \ newest first, reverted ones included, cursor-paginated. A PROVIDER account\
        \ has none: 409 with reason not_a_manual_account."
      operationId: listBankStatementBatches
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: bankAccountId
        required: true
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageStatementBatch"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'bank:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: bank:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                not_a_manual_account:
                  value:
                    detail: Bank account 3f1c0e7b-2d4a-4a5f-9e8c-9b0a1d2e3f40 is connected
                      to a bank — uploads are only for manual accounts
                    error: conflict
                    reason: not_a_manual_account
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not. `reason`\
            \ and the extensions say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - bank:read
      summary: List a manual bank account's uploads
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/bank/accounts/{bankAccountId}/transactions:
    get:
      description: "Cursor-paginated, newest first. reconciliationStatus is computed\
        \ on every read: UNRECONCILED | RECONCILED | STALE."
      operationId: listBankTransactions
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: bankAccountId
        required: true
        schema:
          type: string
          format: uuid
      - description: First date of the range (inclusive).
        in: query
        name: dateFrom
        required: false
        schema:
          type: string
          format: date
      - description: Last date of the range (inclusive).
        in: query
        name: dateTo
        required: false
        schema:
          type: string
          format: date
      - description: UNRECONCILED | RECONCILED | STALE (any case is accepted).
        in: query
        name: reconciliationStatus
        required: false
        schema:
          type: string
          enum:
          - UNRECONCILED
          - RECONCILED
          - STALE
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageBankTransaction"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'bank:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: bank:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - bank:read
      summary: List bank transactions
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/bank/gl-accounts/{glAccountNumber}/summary:
    get:
      description: "One account period of a GL account with the BANK template, summed\
        \ up by the bank approval's rules across every bank account that fed it then:\
        \ closing balances, open lines, the deviation, unmatched counts, stale groups\
        \ and whether the feeds were read through. 404 when the GL account has no\
        \ BANK template in year; 400 account_period_out_of_range for a period its\
        \ period type does not have."
      operationId: getBankGlAccountSummary
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "The GL account's number, e.g. 1920."
        in: path
        name: glAccountNumber
        required: true
        schema:
          type: string
      - description: Accounting year (required; there is no default).
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      - description: "The GL account's period to sum up (required), in its own period\
          \ type: the month on a monthly account, the quarter (1-4) on a quarterly\
          \ one, and so on. 400 account_period_out_of_range when the GL account has\
          \ no such period."
        in: query
        name: accountPeriod
        required: true
        schema:
          type: integer
          format: int32
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BankGlAccountSummary"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                account_period_out_of_range:
                  value:
                    detail: accountPeriod must be between 1 and 4 for the account's
                      period type QUARTERLY
                    error: validation_failed
                    parameter: accountPeriod
                    reason: account_period_out_of_range
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Get a BANK GL account's approval figures for one account period
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/bank/reconciliations:
    post:
      description: "Creates one reconciliation group for a period. A GL line already\
        \ reconciled that year is a 409. Bank transactions and GL lines carry a movement\
        \ with the same sign (a payment is negative on both), so a balanced group's\
        \ GL total minus its bank total is zero. Nothing checks the balance: an unbalanced\
        \ group is accepted as sent. Correction = delete and recreate — groups are\
        \ not editable."
      operationId: createReconciliation
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateReconciliationRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Reconciliation"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            Location:
              description: "The created resource, path-absolute: GET /v1/companies/{companyId}/reconciliations/{id}.\
                \ Also on a replayed response."
              schema:
                type: string
                format: uri-reference
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                already_reconciled:
                  value:
                    detail: "GL lines already reconciled this year: 9f2c-af-1"
                    error: conflict
                    lineIds:
                    - 9f2c-af-1
                    reason: already_reconciled
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                currency_mismatch:
                  value:
                    currency: EUR
                    detail: "GL lines have no amount in EUR: [9f2c-af-1]"
                    error: unprocessable
                    lineIds:
                    - 9f2c-af-1
                    reason: bank_match_currency_mismatch
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Unprocessable
                    type: https://api.accountflow.com/errors/unprocessable
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:write
      summary: Reconcile bank transactions against GL lines
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/blockers:
    get:
      description: |-
        What stops automation for the company: ERP credentials, failed automation, unmapped accounts. Most blocking first.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listBlockers
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageBlockerResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:read
      summary: List automation blockers
      tags:
      - Close
  /v1/companies/{companyId}/close-status:
    get:
      description: "The company's close percentage and close stages for one period.\
        \ The VAT stage is always NA: VAT status is not covered by this API."
      operationId: getCloseStatus
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: MONTHLY (default) | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY
          | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CloseStatusResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Get the month-close status
      tags:
      - Close
  /v1/companies/{companyId}/comments:
    get:
      description: "Newest first, cursor-paginated. The period scope (year, periodType,\
        \ period) is all-or-none, except year alone beside accountId or accountNumber;\
        \ at most one subject filter. VAT comments are not listed here, nor asset\
        \ or payroll comments while that module is off."
      operationId: listComments
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "GL_BALANCE_RECON | GL_LINE_RECON | OPENING_BALANCE_RECON | SUB_LEDGER_OPEN_ITEM_RECON\
          \ | BANK_TRANSACTION_RECON, or another type the app writes. VAT_TERM and\
          \ VAT_REPORT are refused (400); an asset or payroll type while its module\
          \ is off is 403 feature_disabled."
        in: query
        name: commentType
        required: false
        schema:
          type: string
      - description: Account-balance comments on this account (resolved in year's
          ledger).
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: "Accounting year of the period scope, and the ledger accountNumber\
          \ is resolved in. Alone (no periodType or period) only beside accountId\
          \ or accountNumber: the account's year, no period scope."
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: MONTHLY | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY. With year: the comments of that period."
        in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      - description: Comments on this GL line.
        in: query
        name: lineId
        required: false
        schema:
          type: string
      - description: Comments on this opening balance.
        in: query
        name: openingBalanceId
        required: false
        schema:
          type: string
      - description: Comments on this sub-ledger open item.
        in: query
        name: openItemId
        required: false
        schema:
          type: string
          format: uuid
      - description: Comments on this bank line (a bank transaction id).
        in: query
        name: bankTransactionId
        required: false
        schema:
          type: string
          format: uuid
      - description: "Account-balance and account-report comments on this account,\
          \ by the accountId an ACCOUNT subjectKey carries; a year beside it must\
          \ be its own (400 account_year_mismatch)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: "Comments on this accrual (an accrual id, as an ACCRUAL subjectKey\
          \ carries)."
        in: query
        name: accrualId
        required: false
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageCommentResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List comments
      tags:
      - Collaboration
  /v1/companies/{companyId}/contacts:
    get:
      description: "The people documentation requests go to, the default recipient\
        \ first. One page today (pagination.hasMore is false), in the envelope every\
        \ list uses: follow pagination.nextCursor as for any list."
      operationId: listCompanyContacts
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Include deactivated contacts.
        in: query
        name: includeInactive
        required: false
        schema:
          type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyContacts"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: List a company's contacts
      tags:
      - Contacts
    post:
      operationId: createCompanyContact
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCompanyContactRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyContact"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                duplicate_email:
                  value:
                    detail: The company already has an active contact with this email.
                    email: kari@firma.no
                    error: duplicate_resource
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Duplicate Resource
                    type: https://api.accountflow.com/errors/duplicate-resource
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Add a company contact
      tags:
      - Contacts
  /v1/companies/{companyId}/contacts/{contactId}:
    patch:
      description: "Patch semantics: absent fields stay as they are; a deactivated\
        \ contact stays deactivated."
      operationId: updateCompanyContact
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: contactId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCompanyContactRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyContact"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Change a company contact
      tags:
      - Contacts
  /v1/companies/{companyId}/contacts/{contactId}/actions/deactivate:
    post:
      operationId: deactivateCompanyContact
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: contactId
        required: true
        schema:
          type: string
          format: uuid
      - description: The version the contacts read returned; refused with 409 if they
          changed since.
        in: query
        name: expectedVersion
        required: false
        schema:
          type: string
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyContact"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Deactivate a company contact
      tags:
      - Contacts
  /v1/companies/{companyId}/contacts/{contactId}/actions/reactivate:
    post:
      operationId: reactivateCompanyContact
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: contactId
        required: true
        schema:
          type: string
          format: uuid
      - description: The version the contacts read returned; refused with 409 if they
          changed since.
        in: query
        name: expectedVersion
        required: false
        schema:
          type: string
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyContact"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Reactivate a company contact
      tags:
      - Contacts
  /v1/companies/{companyId}/data-freshness:
    get:
      description: "Last general-ledger fetch, the last success and latest attempt\
        \ of each ERP fetch kind, the last import of each dataset type, the sub-ledger\
        \ sync state and the failures of the last 30 days."
      operationId: getDataFreshness
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DataFreshnessResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:read
      summary: Get ERP data freshness
      tags:
      - Company status
  /v1/companies/{companyId}/deadlines:
    get:
      description: |-
        Norwegian VAT, A-melding and tax-return deadlines due between dateFrom and dateTo (default: the next 90 days), soonest first. Due dates are rolled to the next business day.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listDeadlines
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: First due date to include (ISO date); default today.
        in: query
        name: dateFrom
        required: false
        schema:
          type: string
          format: date
      - description: "Last due date to include (ISO date); default dateFrom + 90 days,\
          \ max + 366."
        in: query
        name: dateTo
        required: false
        schema:
          type: string
          format: date
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageDeadlineResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:read
      summary: List regulatory deadlines
      tags:
      - Company status
  /v1/companies/{companyId}/dimensions:
    get:
      description: "The company's dimension values (departments, projects, cost centres,\
        \ ...) by their stable, company-wide keys — the keys general-ledger lines\
        \ refer to."
      operationId: listDimensions
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageMasterDataResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List dimension values
      tags:
      - General Ledger
  /v1/companies/{companyId}/dimensions/{key}:
    delete:
      description: "Delete one dimension value nothing has ever referenced (409 dimension_in_use\
        \ otherwise). All or nothing: if anything requested is in use, the answer\
        \ is 409 with reason and an inUse list of ids and what depends on each, and\
        \ nothing is deleted. Returns 202 with the import to poll; one import or correction\
        \ per kind and company runs at a time."
      operationId: deleteDimension
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: key
        required: true
        schema:
          type: string
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                dimension_in_use:
                  value:
                    detail: "1 dimension is in use and nothing was deleted: remove\
                      \ the dependent work in the application first, or post a reversing\
                      \ line instead"
                    error: conflict
                    inUse:
                    - dependencies:
                      - reconciliation
                      id: INV-2025-000123-1
                    reason: dimension_in_use
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.dimensions' job is already in flight for this
                      scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Delete an unused dimension value
      tags:
      - Imports
  /v1/companies/{companyId}/documents:
    get:
      description: "Oldest first, cursor-paginated. Optional filters: `query` (words\
        \ in the file name); the attachment — `associationType` (ACCOUNT, VOUCHER,\
        \ GL_LINE, COMPANY, RECON_RUN, ERP_LEDGER) with `associationId` (an account\
        \ number — resolved in `year`'s ledger — or account id, a voucher's voucherKey,\
        \ a GL line id — its voucher's documents — or the company/run/ledger id);\
        \ for account attachments a period (`year`, optionally `periodType` + `period`),\
        \ which matches that period's, the whole year's and the account's general\
        \ documents; `uploadedBy` and an upload time range. A caller whose access\
        \ is limited to some of the company's accounts sees no documents attached\
        \ to its other accounts."
      operationId: listDocuments
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Words in the file name.
        in: query
        name: query
        required: false
        schema:
          type: string
      - description: ACCOUNT | VOUCHER | GL_LINE | COMPANY | RECON_RUN | ERP_LEDGER
          (any case).
        in: query
        name: associationType
        required: false
        schema:
          type: string
          enum:
          - ACCOUNT
          - VOUCHER
          - GL_LINE
          - COMPANY
          - RECON_RUN
          - ERP_LEDGER
      - description: The id of what the documents are attached to (with associationType).
        in: query
        name: associationId
        required: false
        schema:
          type: string
      - description: Accounting year of an account attachment's period scope.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: MONTHLY | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY. With year: an account attachment's\
          \ period scope."
        in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      - description: Documents uploaded by this user.
        in: query
        name: uploadedBy
        required: false
        schema:
          type: string
          format: uuid
      - description: Uploaded at or after this instant.
        in: query
        name: uploadedFrom
        required: false
        schema:
          type: string
          format: date-time
      - description: Uploaded before this instant.
        in: query
        name: uploadedTo
        required: false
        schema:
          type: string
          format: date-time
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageDocumentResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:read
      summary: List a company's documents
      tags:
      - Documents
    post:
      description: "Step 1 of 2: declare the document (JSON), receive a signed PUT\
        \ URL, upload the binary directly to storage, then POST /actions/complete.\
        \ The document does not exist until completion."
      operationId: createDocumentUpload
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateUploadRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocumentUploadResponse"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:write
      summary: Start an upload
      tags:
      - Documents
  /v1/companies/{companyId}/flags:
    get:
      description: "Newest first, cursor-paginated. At most one item filter."
      operationId: listFlags
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: ACCOUNT | GL_LINE | ACCRUAL | OPENING_BALANCE | BANK_TRANSACTION.
        in: query
        name: itemType
        required: false
        schema:
          type: string
          enum:
          - ACCOUNT
          - GL_LINE
          - ACCRUAL
          - OPENING_BALANCE
          - BANK_TRANSACTION
      - description: Flags on this account.
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: "The accounting year accountNumber is resolved in; default the\
          \ current one. Beside accountId, it must be that account's year."
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: Flags on this GL line.
        in: query
        name: lineId
        required: false
        schema:
          type: string
      - description: Flags on this accrual.
        in: query
        name: accrualId
        required: false
        schema:
          type: string
          format: uuid
      - description: Flags on this opening balance.
        in: query
        name: openingBalanceId
        required: false
        schema:
          type: string
      - description: Flags on this bank line (a bank transaction id).
        in: query
        name: bankTransactionId
        required: false
        schema:
          type: string
          format: uuid
      - description: "Flags on this account, by the accountId an ACCOUNT flag's subjectKey\
          \ carries; a year beside it must be its own (400 account_year_mismatch)."
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageFlagResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List flagged items
      tags:
      - Collaboration
  /v1/companies/{companyId}/fx-rates:
    get:
      description: "Units of `quoteCurrency` (default the company's base currency)\
        \ per 1 `currency` on `date` (default today), from Norges Bank or, for pairs\
        \ it does not price, the ECB. A non-banking day carries the previous published\
        \ rate forward; `rateDate` is the date of the rate applied. `found` is false\
        \ when no rate exists on or before the date."
      operationId: getFxRate
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The currency to price (ISO 4217).
        example: EUR
        in: query
        name: currency
        required: true
        schema:
          type: string
      - description: The date; default today.
        in: query
        name: date
        required: false
        schema:
          type: string
          format: date
      - description: The currency to price it in; default the company's base currency.
        example: NOK
        in: query
        name: quoteCurrency
        required: false
        schema:
          type: string
      - description: "Force one provider: NORGES_BANK or ECB."
        in: query
        name: source
        required: false
        schema:
          type: string
          enum:
          - NORGES_BANK
          - ECB
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FxRateResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: Get a reference exchange rate
      tags:
      - General Ledger
  /v1/companies/{companyId}/general-ledger/lines:
    get:
      description: "Cursor-paginated GL lines for one accounting year, ordered by\
        \ period then line id. Zero-amount lines are included. Line ids are stable\
        \ across re-imports. Each line carries its sub-ledger and dimension keys,\
        \ its settlement status, its attachment count and its `voucherKey` (the value\
        \ a document's `VOUCHER` association takes). The first page (no cursor) carries\
        \ `totals` over every line the filters match: line count, debit, credit and\
        \ net."
      operationId: listGeneralLedgerLines
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: Filter to one account number.
        example: 3000
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: "Month of the accounting year, 1-12: the calendar month when\
          \ the year starts in January. Only lines posted in it."
        in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      - description: Filter to one ERP VAT code.
        example: 3
        in: query
        name: taxCode
        required: false
        schema:
          type: string
      - description: "Earliest posting date, inclusive (lines without a posting date\
          \ are excluded)."
        in: query
        name: dateFrom
        required: false
        schema:
          type: string
          format: date
      - description: "Latest posting date, inclusive (lines without a posting date\
          \ are excluded)."
        in: query
        name: dateTo
        required: false
        schema:
          type: string
          format: date
      - description: "Smallest signed base-currency amount, inclusive (credits are\
          \ negative)."
        in: query
        name: amountMin
        required: false
        schema:
          type: number
      - description: "Largest signed base-currency amount, inclusive."
        in: query
        name: amountMax
        required: false
        schema:
          type: number
      - description: "Filter to one voucher (bilag) number, exact."
        in: query
        name: voucherNo
        required: false
        schema:
          type: string
      - description: Filter to one voucher by its id (`voucherId` from searchVouchers).
        in: query
        name: voucherId
        required: false
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GlLinesResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List general-ledger lines
      tags:
      - General Ledger
  /v1/companies/{companyId}/imports:
    get:
      description: "The company's imports and corrections, newest first."
      operationId: listImports
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageImportResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: List imports
      tags:
      - Imports
  /v1/companies/{companyId}/imports/accounts:
    post:
      description: "Push up to 10 000 accounts for one accounting year. Existing account\
        \ codes are updated in place; their standard-account mapping is preserved.\
        \ The company must be bound to the Api accounting system (409 company_not_api_managed\
        \ otherwise), and one accounts import per company runs at a time (409 job_in_flight).\
        \ Returns 202 with the import; poll it, or the job it names, until succeeded\
        \ or failed."
      operationId: importAccounts
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AccountsImportRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.accounts' job is already in flight for this
                      scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
                too_many_lines:
                  value:
                    detail: accounts holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    limit: 10000
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Import the chart of accounts
      tags:
      - Imports
  /v1/companies/{companyId}/imports/dimensions:
    post:
      description: "Push up to 10 000 dimension values (departments, projects, cost\
        \ centres, ...). Keys are company-wide and stable; an existing key is updated\
        \ in place. Returns 202 with the import."
      operationId: importDimensions
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DimensionsImportRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.dimensions' job is already in flight for this
                      scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
                too_many_lines:
                  value:
                    detail: dimensions holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    limit: 10000
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Import dimension values
      tags:
      - Imports
  /v1/companies/{companyId}/imports/general-ledger-lines:
    post:
      description: "Push up to 10 000 general-ledger lines for one accounting year.\
        \ Lines are merged by id: a known id is updated in place, a new one inserted;\
        \ nothing is removed. Every accountCode must already be in the chart for that\
        \ year (422 unknown_account_codes otherwise); unknown dimension and sub-ledger\
        \ keys are created. Periods are 1–12. Returns 202 with the import."
      operationId: importGeneralLedgerLines
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GlLinesImportRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.general_ledger_lines' job is already in flight
                      for this scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
                too_many_lines:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    limit: 10000
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
                unknown_account_codes:
                  value:
                    accountCodes:
                    - "3990"
                    - "7790"
                    detail: 2 account code(s) are not in the company's chart for 2026;
                      import the accounts first
                    error: unprocessable
                    reason: unknown_account_codes
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Unprocessable
                    type: https://api.accountflow.com/errors/unprocessable
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Import general-ledger lines
      tags:
      - Imports
  /v1/companies/{companyId}/imports/general-ledger-lines/deletions:
    post:
      description: "Delete up to 10 000 lines of one accounting year by the ids they\
        \ were pushed with. A line is in use once it is matched, reconciled, commented,\
        \ flagged, accrued, or tied to an asset or payroll (409 lines_in_use). Deleted\
        \ lines keep their full history; ids the ledger does not have are reported\
        \ on the import, not errors. To change a line's values, re-send it with the\
        \ same id instead. All or nothing: if anything requested is in use, the answer\
        \ is 409 with reason and an inUse list of ids and what depends on each, and\
        \ nothing is deleted. Returns 202 with the import to poll; one import or correction\
        \ per kind and company runs at a time."
      operationId: deleteGeneralLedgerLines
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeletionRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.general_ledger_lines' job is already in flight
                      for this scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                lines_in_use:
                  value:
                    detail: "1 line(s) are in use and nothing was deleted: remove\
                      \ the dependent work in the application first, or post a reversing\
                      \ line instead"
                    error: conflict
                    inUse:
                    - dependencies:
                      - reconciliation
                      id: INV-2025-000123-1
                    reason: lines_in_use
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
                too_many_lines:
                  value:
                    detail: ids holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    limit: 10000
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Delete general-ledger lines
      tags:
      - Imports
  /v1/companies/{companyId}/imports/open-items:
    post:
      description: "Push up to 10 000 customer or supplier open items with their matches.\
        \ incremental updates what is sent and sourceDeleted retires an item; full,\
        \ full_refresh and baseline snapshots retire items and matches absent from\
        \ the snapshot. The whole import fails on any invalid item. Returns 202 with\
        \ the import."
      operationId: importOpenItems
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OpenItemsImportRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.open_items' job is already in flight for this
                      scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
                too_many_lines:
                  value:
                    detail: items holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    limit: 10000
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Import sub-ledger open items
      tags:
      - Imports
  /v1/companies/{companyId}/imports/opening-balances:
    post:
      description: Push up to 10 000 opening-balance rows for one accounting year.
        Every accountCode must already be in the chart for that year (422 unknown_account_codes
        otherwise); re-sending an id updates the row. Returns 202 with the import.
      operationId: importOpeningBalances
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OpeningBalancesImportRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.opening_balances' job is already in flight for
                      this scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
                too_many_lines:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    limit: 10000
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
                unknown_account_codes:
                  value:
                    accountCodes:
                    - "3990"
                    - "7790"
                    detail: 2 account code(s) are not in the company's chart for 2026;
                      import the accounts first
                    error: unprocessable
                    reason: unknown_account_codes
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Unprocessable
                    type: https://api.accountflow.com/errors/unprocessable
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Import opening balances
      tags:
      - Imports
  /v1/companies/{companyId}/imports/opening-balances/deletions:
    post:
      description: "Delete opening-balance rows of one accounting year by the ids\
        \ they were pushed with. A row is in use once it has been split, itemised,\
        \ matched or commented (409 opening_balances_in_use). The trial balance's\
        \ opening column is recomputed. All or nothing: if anything requested is in\
        \ use, the answer is 409 with reason and an inUse list of ids and what depends\
        \ on each, and nothing is deleted. Returns 202 with the import to poll; one\
        \ import or correction per kind and company runs at a time."
      operationId: deleteOpeningBalances
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeletionRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.opening_balances' job is already in flight for
                      this scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                opening_balances_in_use:
                  value:
                    detail: "1 opening-balance row(s) are in use and nothing was deleted:\
                      \ remove the dependent work in the application first, or post\
                      \ a reversing line instead"
                    error: conflict
                    inUse:
                    - dependencies:
                      - reconciliation
                      id: INV-2025-000123-1
                    reason: opening_balances_in_use
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
                too_many_lines:
                  value:
                    detail: ids holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    limit: 10000
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Delete opening-balance rows
      tags:
      - Imports
  /v1/companies/{companyId}/imports/readiness:
    get:
      description: "Preflight before importing: whether the company is bound to the\
        \ Api accounting system, what each API-managed year already holds, and the\
        \ next step. An unbound company is reported in blockers, not refused."
      operationId: getImportReadiness
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportReadinessResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Check import readiness
      tags:
      - Imports
  /v1/companies/{companyId}/imports/sub-ledgers:
    post:
      description: "Push up to 10 000 sub-ledger parties (customers, suppliers, ...).\
        \ Each partyKey is company-wide and stable; an existing one is updated in\
        \ place. Returns 202 with the import."
      operationId: importSubLedgers
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SubLedgersImportRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.sub_ledgers' job is already in flight for this
                      scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
                too_many_lines:
                  value:
                    detail: subLedgers holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    limit: 10000
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Import sub-ledgers
      tags:
      - Imports
  /v1/companies/{companyId}/imports/trial-balance:
    post:
      description: "Push a monthly trial balance for one accounting year (up to 10\
        \ 000 rows): per account and month, the closing balance at the month's end,\
        \ and for balance-sheet accounts the year's opening balance. The history of\
        \ a company moved from another system: accounts the chart lacks are created,\
        \ balance-sheet accounts get their opening balance, and every month an account\
        \ has a closing for gets one line with its movement, dated the month's last\
        \ day. Re-sending a month updates it and leaves later closings unchanged.\
        \ The company must be managed through the API for that year (409 company_not_api_managed;\
        \ create the year's Api ledger first), and the year must hold no postings\
        \ a trial balance did not write (409 foreign_gl_lines). Until the trial-balance\
        \ import is enabled for the deployment, every request answers 409 trial_balance_import_unavailable\
        \ and nothing is written. Returns 202 with the import; poll it, or the job\
        \ it names, until succeeded or failed."
      operationId: importTrialBalance
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TrialBalanceImportRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A job of this kind is already in flight for this scope;
                      poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Import a monthly trial balance
      tags:
      - Imports
  /v1/companies/{companyId}/imports/{importId}:
    get:
      description: "Status, row counters, line errors and the job and dataset ids\
        \ of one import."
      operationId: getImport
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: importId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Get an import
      tags:
      - Imports
  /v1/companies/{companyId}/intercompany/definitions:
    get:
      description: "Per counterparty: the reconciliation lines and the accounts on\
        \ each. One page today (pagination.hasMore is false), in the envelope every\
        \ list uses: follow pagination.nextCursor as for any list."
      operationId: listIntercompanyDefinitions
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Include deactivated links.
        in: query
        name: includeInactive
        required: false
        schema:
          type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinitions"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: List the company's intercompany counterparty links
      tags:
      - Intercompany
    post:
      description: Another member of a group the company belongs to. The link starts
        without lines.
      operationId: createIntercompanyDefinition
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateIntercompanyDefinitionRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinition"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            Location:
              description: "The created resource, path-absolute: GET /v1/companies/{companyId}/intercompany/definitions/{id}.\
                \ Also on a replayed response."
              schema:
                type: string
                format: uri-reference
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Link the company to an intercompany counterparty
      tags:
      - Intercompany
  /v1/companies/{companyId}/intercompany/definitions/{definitionId}:
    get:
      operationId: getIntercompanyDefinition
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: definitionId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinition"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: Get one intercompany counterparty link
      tags:
      - Intercompany
    patch:
      description: "Patch semantics. A link is never deleted: `active: false` deactivates\
        \ it."
      operationId: updateIntercompanyDefinition
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: definitionId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateIntercompanyDefinitionRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinition"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Change an intercompany counterparty link
      tags:
      - Intercompany
  /v1/companies/{companyId}/intercompany/definitions/{definitionId}/accounts:
    post:
      description: "The whole account, or one sub-ledger party or dimension value\
        \ of it. Each part of an account belongs to one link (409 with a reason otherwise)."
      operationId: linkIntercompanyAccount
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: definitionId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LinkIntercompanyAccountRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinition"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Put an account on a counterparty link
      tags:
      - Intercompany
  /v1/companies/{companyId}/intercompany/definitions/{definitionId}/accounts/{accountLinkId}:
    delete:
      operationId: unlinkIntercompanyAccount
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: definitionId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: accountLinkId
        required: true
        schema:
          type: string
          format: uuid
      - description: The version the link's read returned; refused with 409 if it
          changed since.
        in: query
        name: expectedVersion
        required: false
        schema:
          type: string
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinition"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Take an account off a counterparty link
      tags:
      - Intercompany
    patch:
      operationId: moveIntercompanyAccount
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: definitionId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: accountLinkId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MoveIntercompanyAccountRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinition"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Move an account to another line of the same link
      tags:
      - Intercompany
  /v1/companies/{companyId}/intercompany/definitions/{definitionId}/lines:
    post:
      operationId: addIntercompanyLine
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: definitionId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AddIntercompanyLineRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinition"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Add a reconciliation line to a counterparty link
      tags:
      - Intercompany
  /v1/companies/{companyId}/intercompany/definitions/{definitionId}/lines/{lineId}:
    delete:
      description: "Refused (409) while anything uses the line, and for the link's\
        \ last line."
      operationId: deleteIntercompanyLine
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: definitionId
        required: true
        schema:
          type: string
          format: uuid
      - description: The intercompany reconciliation line's id (a uuid; not a general-ledger
          lineId).
        in: path
        name: lineId
        required: true
        schema:
          type: string
          format: uuid
      - description: The version the link's read returned; refused with 409 if it
          changed since.
        in: query
        name: expectedVersion
        required: false
        schema:
          type: string
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinition"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Delete an empty reconciliation line
      tags:
      - Intercompany
    patch:
      description: Patch semantics.
      operationId: updateIntercompanyLine
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: definitionId
        required: true
        schema:
          type: string
          format: uuid
      - description: The intercompany reconciliation line's id (a uuid; not a general-ledger
          lineId).
        in: path
        name: lineId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateIntercompanyLineRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyDefinition"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Change a reconciliation line
      tags:
      - Intercompany
  /v1/companies/{companyId}/intercompany/groups:
    get:
      description: "The groups the company belongs to and their members: the counterparties\
        \ it can link to. One page today (pagination.hasMore is false), in the envelope\
        \ every list uses: follow pagination.nextCursor as for any list."
      operationId: listIntercompanyGroups
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntercompanyGroups"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: List the company's intercompany groups
      tags:
      - Intercompany
  /v1/companies/{companyId}/ledgers:
    get:
      description: "The company's ledgers, newest first: one per accounting year and\
        \ accounting system, which system each is bound to (apiManaged for the Api\
        \ accounting system, the ledgers imports write) and which one is current.\
        \ A year has more than one ledger when the company changed systems that year;\
        \ reads of that year use the current one, else the newest. Filter by year;\
        \ cursor-paginated."
      operationId: listLedgers
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Only the ledgers of this accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
          nullable: true
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
          nullable: true
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageLedgerResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: List a company's ledgers
      tags:
      - Imports
    post:
      description: "Create the company's ledger for one accounting year (2000 to next\
        \ year) bound to the Api accounting system, with the year's fiscal-year row\
        \ when it has none: the step that moves a company from a worker-fed accounting\
        \ system to the API. It becomes the company's current ledger when setCurrent\
        \ is true (whatever its year), or when the company has no current ledger or\
        \ its current one holds no general-ledger lines; otherwise it is created beside\
        \ the current ledger, which stays current, and the answer says current: false.\
        \ Imports need the current ledger on the Api system, so the year a company\
        \ switches takes setCurrent: true. The ledgers of other systems keep their\
        \ data and stay listed. A year that has an Api ledger already is refused with\
        \ 409 ledger_exists (its ledgerId in the problem); a company with an ERP fetch\
        \ in progress with 409 fetch_in_progress (its data would land on the new ledger);\
        \ a year that would overlap another fiscal year with 409 fiscal_year_overlap."
      operationId: createApiLedger
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateApiLedgerRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerResponse"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Create the year's Api ledger
      tags:
      - Imports
  /v1/companies/{companyId}/opening-balances:
    get:
      description: "Cursor-paginated, aggregates before their items. An aggregate\
        \ that is broken down into items (customer/supplier documents, ...) shows\
        \ the unspecified residual as its amount. Address the account by `accountNumber`\
        \ (+ `year`) or `accountId`."
      operationId: listOpeningBalances
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1500
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: The account id; wins over accountNumber.
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageAccountOpeningBalanceResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List the lines behind an account's opening balance
      tags:
      - Account detail
  /v1/companies/{companyId}/reconciliation-adjustments:
    get:
      description: |-
        The manual explanation lines (utjevn avvik) added to an account-period, newest first. `periodType` defaults to the account's reconciliation frequency.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listReconciliationAdjustments
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1920
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: The account id; wins over accountNumber.
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Cadence of period: MONTHLY, BIMONTHLY, QUARTERLY, TERTIARY,\
          \ HALF_YEARLY or YEARLY; default the account's reconciliation frequency."
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageReconciliationAdjustmentResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List an account-period's reconciliation adjustments
      tags:
      - Account detail
  /v1/companies/{companyId}/reconciliation-runs:
    get:
      description: "The company's automatic reconciliation runs, newest first: ordered\
        \ through the API, in the app, and CAR's scheduled runs. Filter by status\
        \ and by since (requested at or after)."
      operationId: listReconciliationRuns
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Only runs in this status.
        in: query
        name: status
        required: false
        schema:
          type: string
          enum:
          - PENDING
          - PROCESSING
          - SUCCEEDED
          - FAILED
          - SKIPPED
      - description: Only runs requested at or after this instant (ISO-8601).
        in: query
        name: since
        required: false
        schema:
          type: string
          format: date-time
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageReconciliationRun"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List reconciliation runs
      tags:
      - Reconciliation runs
    post:
      description: "Orders an automatic reconciliation run now for each of 1 to 50\
        \ accounts of one accounting year. 202 with one entry per account, in the\
        \ order given: ACCEPTED with the runId, NOT_ENABLED when automatic reconciliation\
        \ is off for the company, or SKIPPED (reason rate_limited, with retryAfterSeconds)\
        \ when the account was ordered in the last 15 minutes. Nothing is ordered\
        \ when an account is unknown (404), belongs to another year (400) or is listed\
        \ twice (400). Follow a run with GET …/reconciliation-runs/{runId}; its deviations\
        \ are read with the account reconciliation."
      operationId: requestReconciliationRun
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RequestRunsRequest"
        required: true
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RequestedRuns"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:run' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:run
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:run
      summary: Order reconciliation runs for accounts
      tags:
      - Reconciliation runs
  /v1/companies/{companyId}/reconciliation-runs/{runId}:
    get:
      description: "One run: its status, reason and error, when it was requested,\
        \ started and finished, and each account's task status. A run of another company\
        \ is 404."
      operationId: getReconciliationRun
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: runId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReconciliationRun"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Get a reconciliation run
      tags:
      - Reconciliation runs
  /v1/companies/{companyId}/reconciliations/{reconciliationGroupId}:
    delete:
      description: Dissolves the group; its transactions and GL lines become unreconciled
        again.
      operationId: deleteReconciliation
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: reconciliationGroupId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeletionResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:write
      summary: Unmatch a reconciliation group
      tags:
      - Bank & Reconciliation
    get:
      operationId: getReconciliation
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: reconciliationGroupId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Reconciliation"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Get one reconciliation group with its entries
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/settings:
    get:
      description: "Modules, base currency (the current accounting year's, and each\
        \ year's with where it came from), responsible people and automatic reconciliation.\
        \ Readable by those who may read the company's settings in the application\
        \ — not by viewers or auditors."
      operationId: getCompanySettings
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanySettings"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: Get a company's settings
      tags:
      - Company settings
    patch:
      description: "Modules, base currency, responsible people and automatic reconciliation,\
        \ in one change: everything named applies together or not at all, under one\
        \ expectedVersion. Patch semantics: absent fields stay unchanged. Automatic\
        \ approval (autoApprove) can only be on while automatic reconciliation is\
        \ on, for the company and for each module. A person must belong to the company's\
        \ organization and be able to read the company. Changing settings is for company\
        \ and organization admins."
      operationId: updateCompanySettings
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCompanySettingsRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanySettings"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Change a company's settings
      tags:
      - Company settings
  /v1/companies/{companyId}/settings/automation:
    patch:
      description: "The company defaults. Patch semantics: absent fields stay unchanged.\
        \ autoApprove and autoPostOnHighConfidence let the platform approve or post\
        \ without a person."
      operationId: updateCompanyAutomation
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCompanyAutomationRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanySettings"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Change a company's automatic reconciliation
      tags:
      - Company settings
  /v1/companies/{companyId}/settings/automation/modules/{module}:
    patch:
      description: "Absent fields stay as they are, and every other value the module\
        \ stores is kept; fields named in reset inherit again. The group window, the\
        \ bank second pass and automatic corrections are BANK's only; the thresholds\
        \ (flagPercent, flagFloorNok, flagAbsoluteNok, highPercent, highFloorNok)\
        \ are the currency controls' (CURRENCY_K28, CURRENCY_K29), which never approve.\
        \ A refused threshold is a 400 with reason threshold_negative, threshold_too_many_decimals,\
        \ threshold_out_of_range or threshold_high_below_flag."
      operationId: updateCompanyAutomationModule
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: module
        required: true
        schema:
          type: string
          enum:
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - GENERAL_LEDGER
          - BALANCE
          - ACCRUALS
          - ASSETS
          - VAT
          - PAYROLL
          - CURRENCY_K28
          - CURRENCY_K29
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCompanyAutomationModuleRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanySettings"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                stale_version:
                  value:
                    currentVersion: 3f9a1c0e7b2d4a5f6e8c9b0a
                    detail: The settings changed since they were read; read them again
                      and retry with the new version.
                    error: conflict
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); the settings changed since the version\
            \ you named (currentVersion, or currentRevision on an account, is the\
            \ one now). `reason` and the extensions say which; the examples show this\
            \ operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:write
      summary: Override automatic reconciliation for one module
      tags:
      - Company settings
  /v1/companies/{companyId}/settlements:
    get:
      description: "Newest first, cursor-paginated. Manual and automatic settlements\
        \ with their lines, amount, difference, partial state, automatcher confidence\
        \ and who made them. Address the account by `accountNumber` (+ `year`) or\
        \ `accountId`."
      operationId: listSettlements
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The account number.
        example: 1500
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: The account id; wins over accountNumber.
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: The accounting year accountNumber is resolved in; default the
          current one.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: MONTHLY | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY. Only settlements of that period."
        in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      - description: AUTO | MANUAL (any case).
        in: query
        name: type
        required: false
        schema:
          type: string
          enum:
          - AUTO
          - MANUAL
      - description: SETTLED | PARTIAL (any case).
        in: query
        name: status
        required: false
        schema:
          type: string
          enum:
          - SETTLED
          - PARTIAL
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageSettlementResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List settlements on an account
      tags:
      - Settlements
  /v1/companies/{companyId}/settlements/{settlementId}:
    get:
      description: "The settlement a general-ledger line's or an opening balance's\
        \ `settlementId` names, in the shape listSettlements returns: its lines, amount,\
        \ difference, partial state, automatcher confidence and who made it. A settlement\
        \ of another company is a 404."
      operationId: getSettlement
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The settlement's id (`settlementId` on a GL line or an opening
          balance).
        in: path
        name: settlementId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SettlementResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Get one settlement
      tags:
      - Settlements
  /v1/companies/{companyId}/standard-accounts:
    get:
      description: "The standard accounts of the company's country. One page today\
        \ (pagination.hasMore is false), in the envelope every list uses: follow pagination.nextCursor\
        \ as for any list."
      operationId: listStandardAccounts
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Number prefix or words of the description.
        in: query
        name: query
        required: false
        schema:
          type: string
      - description: Only this standard account.
        in: query
        name: standardAccountId
        required: false
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StandardAccounts"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: List the standard accounts a company can map to
      tags:
      - Account mapping
  /v1/companies/{companyId}/sub-ledgers:
    get:
      description: "The company's sub-ledger parties (customers, suppliers, ...) by\
        \ their stable, company-wide partyKey — the partyKey of open items and the\
        \ partyKeys of general-ledger lines and opening balances."
      operationId: listSubLedgers
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageSubLedgerResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List sub-ledgers
      tags:
      - General Ledger
  /v1/companies/{companyId}/sub-ledgers/open-items:
    get:
      description: "Customer and supplier open items as they stood on `asOfDate` (default\
        \ today, Oslo time), with days overdue and the aging bucket by due date (NO_DUE_DATE,\
        \ NOT_DUE, 0-30, 31-60, 61-90, 91+ days past due). `agingTotals` covers every\
        \ item the filters match, not only the page. Items settled by `asOfDate` are\
        \ left out unless `includeSettled=true`."
      operationId: listOpenItems
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: The as-of date; default today.
        in: query
        name: asOfDate
        required: false
        schema:
          type: string
          format: date
      - description: Control account number.
        example: 1500
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: The account id; wins over accountNumber.
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: CUSTOMER or SUPPLIER (any case is accepted).
        in: query
        name: subLedgerType
        required: false
        schema:
          type: string
          enum:
          - CUSTOMER
          - SUPPLIER
      - description: "One party's partyKey, as listSubLedgers returns it."
        in: query
        name: partyKey
        required: false
        schema:
          type: string
      - description: Include items settled by asOfDate.
        in: query
        name: includeSettled
        required: false
        schema:
          type: boolean
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OpenItemsResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: List sub-ledger open items as of a date
      tags:
      - Sub-ledgers
  /v1/companies/{companyId}/sub-ledgers/reconciliation:
    get:
      description: "Per control account and sub-ledger type: the general-ledger control\
        \ balance, the sum of the party-tagged balances, the untagged difference,\
        \ the double-counted overlap and a BALANCED/BREAK verdict, cumulative through\
        \ `period` (0–12; 0 = opening balance only). `includeParties` adds per-party\
        \ balances; `asOfDate` adds the open-item totals."
      operationId: getSubLedgerReconciliation
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Month of the accounting year, 0-12: 0 is the opening balance\
          \ only, 1-12 the calendar month when the year starts in January. The balances\
          \ are cumulative through it."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: One control account number.
        example: 1500
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: The account id; wins over accountNumber.
        in: query
        name: accountId
        required: false
        schema:
          type: string
          format: uuid
      - description: CUSTOMER or SUPPLIER (any case is accepted).
        in: query
        name: subLedgerType
        required: false
        schema:
          type: string
          enum:
          - CUSTOMER
          - SUPPLIER
      - description: Add open-item totals as of this date (usually the period end).
        in: query
        name: asOfDate
        required: false
        schema:
          type: string
          format: date
      - description: Include per-party balances.
        in: query
        name: includeParties
        required: false
        schema:
          type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SubLedgerReconciliationResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Reconcile sub-ledgers against their control accounts
      tags:
      - Sub-ledgers
  /v1/companies/{companyId}/sub-ledgers/{partyKey}:
    delete:
      description: "Delete one sub-ledger nothing has ever referenced (409 sub_ledger_in_use\
        \ otherwise). All or nothing: if anything requested is in use, the answer\
        \ is 409 with reason and an inUse list of ids and what depends on each, and\
        \ nothing is deleted. Returns 202 with the import to poll; one import or correction\
        \ per kind and company runs at a time."
      operationId: deleteSubLedger
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "The party's key, as list_sub_ledgers returns it."
        in: path
        name: partyKey
        required: true
        schema:
          type: string
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "202":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImportResponse"
          description: "Accepted: the work runs asynchronously. Poll the returned\
            \ resource (and its jobId at GET /v1/jobs/{jobId}) until its status is\
            \ terminal. A retry with the same Idempotency-Key returns this same response\
            \ with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'imports:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: imports:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_not_api_managed:
                  value:
                    detail: "This company is not managed through the API: bind it\
                      \ to the Api accounting system in the application before importing"
                    error: conflict
                    reason: company_not_api_managed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                job_in_flight:
                  value:
                    detail: A 'import.sub_ledgers' job is already in flight for this
                      scope; poll it or wait for it to finish
                    error: conflict
                    jobId: 7b0e2c4a-5d1f-4e3b-9a8c-2f6d1e0b3a47
                    reason: job_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                sub_ledger_in_use:
                  value:
                    detail: "1 sub-ledger is in use and nothing was deleted: remove\
                      \ the dependent work in the application first, or post a reversing\
                      \ line instead"
                    error: conflict
                    inUse:
                    - dependencies:
                      - reconciliation
                      id: INV-2025-000123-1
                    reason: sub_ledger_in_use
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only); a job of this kind already runs for\
            \ the company (job_in_flight; jobId names it). `reason` and the extensions\
            \ say which; the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - imports:write
      summary: Delete an unused sub-ledger
      tags:
      - Imports
  /v1/companies/{companyId}/tasks:
    get:
      description: "The findings Accountflow's rules keep on the company, its accounts\
        \ and its intercompany definitions, cursor-paginated: severity first (HIGH,\
        \ MEDIUM, LOW), then the work due date (none last), then the age of the current\
        \ episode. Without `status`, OPEN and BLOCKED only; a client with a linked\
        \ person does not see that person's snoozed or hidden tasks unless it asks.\
        \ An ACCOUNT task's `accountNumber` and `year` address `GET /companies/{companyId}/accounts/{accountNumber}/reconciliation`.\
        \ Only a caller who sees every account of the company sees its tasks; for\
        \ anyone else the company's tasks are a 404."
      operationId: listTasks
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Only tasks in these statuses (repeat the parameter or separate\
          \ with commas); default OPEN,BLOCKED."
        in: query
        name: status
        required: false
        schema:
          type: array
          items:
            type: string
            enum:
            - OPEN
            - BLOCKED
            - RESOLVED
            - WAIVED
            - SUPERSEDED
            - NOT_APPLICABLE
            - MANUAL_CLOSED
      - description: "Only this rule's tasks (rule.code, for example L01)."
        in: query
        name: rule
        required: false
        schema:
          type: string
      - description: Only tasks on this kind of target.
        in: query
        name: targetType
        required: false
        schema:
          type: string
          enum:
          - COMPANY
          - ACCOUNT
          - INTERCOMPANY
      - description: "Only tasks on this target (target.key): an account number, the\
          \ company's id, or an intercompany definition's id."
        in: query
        name: targetKey
        required: false
        schema:
          type: string
      - description: "Only tasks for this period key (periodKey): NONE, FY:<year>\
          \ or TERM:<periodType>:<year>:<period>."
        in: query
        name: periodKey
        required: false
        schema:
          type: string
      - description: "me, none (unassigned) or a user id."
        in: query
        name: assignee
        required: false
        schema:
          type: string
      - description: Also the tasks your linked person snoozed; default false.
        in: query
        name: includeSnoozed
        required: false
        schema:
          type: boolean
      - description: Also the tasks your linked person hid; default false.
        in: query
        name: includeHidden
        required: false
        schema:
          type: boolean
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageTaskResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List a company's tasks
      tags:
      - Tasks
  /v1/companies/{companyId}/tasks/{taskId}:
    get:
      description: "The task, every episode (each time it opened, and how it closed)\
        \ and its latest 50 changes, newest first. The company in the path must be\
        \ the task's, or the answer is 404."
      operationId: getTask
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: taskId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskDetailResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Get one task with its history
      tags:
      - Tasks
  /v1/companies/{companyId}/trial-balance:
    get:
      description: "Opening balance, labeled monthly movements, and closing balance\
        \ per account for one accounting year. The closing balance at period N is\
        \ openingBalance plus the movements of periods 1..N. Each row carries the\
        \ account number and that year's `accountId`. The accounts are cursor-paginated\
        \ by account number; `totals` sum every account of the year and are the same\
        \ on every page."
      operationId: getTrialBalance
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TrialBalanceResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: Get the trial balance
      tags:
      - General Ledger
  /v1/companies/{companyId}/users:
    get:
      description: |-
        The company's organization's administrators and the people an access policy gives the company, each a person in the organization who can read it: the user ids the settings take as `ownerUserId`, `controllerUserId`, `mainAccountantUserId`, `auditorUserId` and an account's `ownerUserId`. Administrators of a parent organization can be named too but are not listed, as in the application's Users tab.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listCompanyUsers
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageCompanyUserResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'settings:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: settings:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - settings:read
      summary: List the people who can be named in a company's settings
      tags:
      - Users
  /v1/companies/{companyId}/vat/terms:
    get:
      description: |-
        The company's VAT filing terms with their reconciliation status and totals (decimal NOK).

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listVatTerms
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Only the terms of this filing year; omitted = every year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageVatTermResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'companyId'
                    error: validation_failed
                    parameter: companyId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'vat:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: vat:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - vat:read
      summary: List VAT filing terms
      tags:
      - VAT
  /v1/companies/{companyId}/vouchers:
    get:
      description: "The company's vouchers (bilag), newest first, cursor-paginated.\
        \ `query` is a case-insensitive contains over the voucher number, text and\
        \ document reference; `year` (+ `period`) and `accountNumber` match vouchers\
        \ with at least one such line."
      operationId: searchVouchers
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Text to look for in the number, text and document reference."
        in: query
        name: query
        required: false
        schema:
          type: string
      - description: Accounting year of the voucher's lines; omitted = every year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Month of the accounting year, 1-12: the calendar month when\
          \ the year starts in January. Requires year."
        in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      - description: Vouchers with a line on this account.
        example: 3000
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageVoucherResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'ledger:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: ledger:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - ledger:read
      summary: Search vouchers
      tags:
      - General Ledger
  /v1/companies/{companyId}/work-queue:
    get:
      description: "The company's close work for one period, most urgent first. Items\
        \ the calling person marked done or snoozed are left out unless includeDismissed=true."
      operationId: listWorkQueue
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year; omitted = the current accounting year.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: MONTHLY (default) | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY
          | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: Also return items marked done or snoozed.
        in: query
        name: includeDismissed
        required: false
        schema:
          type: boolean
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageWorkQueueItemResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List the close work queue
      tags:
      - Close
  /v1/documents/{documentId}:
    delete:
      description: "Soft delete: the document 404s until restored; the binary stays\
        \ in storage. Idempotent."
      operationId: deleteDocument
      parameters:
      - in: path
        name: documentId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeletionResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'documentId'
                    error: validation_failed
                    parameter: documentId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:write
      summary: Delete a document
      tags:
      - Documents
    get:
      operationId: getDocument
      parameters:
      - in: path
        name: documentId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocumentResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'documentId'
                    error: validation_failed
                    parameter: documentId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:read
      summary: Get a document's metadata
      tags:
      - Documents
    patch:
      operationId: renameDocument
      parameters:
      - in: path
        name: documentId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RenameRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocumentResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'documentId'
                    error: validation_failed
                    parameter: documentId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:write
      summary: Rename a document
      tags:
      - Documents
  /v1/documents/{documentId}/actions/complete:
    post:
      description: "Step 2 of 2: after the binary is uploaded, verifies the object\
        \ (size and content type must match the declaration), scans it for malware\
        \ and creates the document. Emits document.uploaded. A file that fails the\
        \ content or malware check (422 `malware_detected`) is deleted; upload it\
        \ again to the same slot."
      operationId: completeDocumentUpload
      parameters:
      - in: path
        name: documentId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocumentResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'documentId'
                    error: validation_failed
                    parameter: documentId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
                upload_not_completed:
                  value:
                    detail: The binary has not been uploaded to the signed URL yet
                    error: conflict
                    reason: upload_not_completed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
                malware_detected:
                  value:
                    detail: The file was rejected by the virus scan.
                    error: malware_detected
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Malware Detected
                    type: https://api.accountflow.com/errors/malware-detected
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:write
      summary: Complete an upload
      tags:
      - Documents
  /v1/documents/{documentId}/actions/restore:
    post:
      description: Idempotent.
      operationId: restoreDocument
      parameters:
      - in: path
        name: documentId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocumentResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'documentId'
                    error: validation_failed
                    parameter: documentId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:write
      summary: Restore a deleted document
      tags:
      - Documents
  /v1/documents/{documentId}/associations:
    get:
      description: "Every connection the document has had, oldest first, removed ones\
        \ included (with `detachedAt`), cursor-paginated. A deleted document's connections\
        \ are listed too."
      operationId: listDocumentAssociations
      parameters:
      - in: path
        name: documentId
        required: true
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageDocumentAssociation"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:read
      summary: List a document's connections
      tags:
      - Documents
    post:
      description: "Connects an existing document to an account of its company (for\
        \ one period, a year or in general), a general-ledger line, an opening balance,\
        \ a voucher, the company itself, a reconciliation run or an ERP ledger. For\
        \ an account, `year` picks the ledger an `accountNumber` is resolved in and\
        \ is the year the connection is for; `period` narrows it to one period in\
        \ the account's own cadence. A target outside the company is `404`; a connection\
        \ the document already has (same target and start) is `409 duplicate_resource`\
        \ with the existing `connectionId`."
      operationId: linkDocument
      parameters:
      - in: path
        name: documentId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LinkDocumentRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocumentAssociation"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'documentId'
                    error: validation_failed
                    parameter: documentId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:write
      summary: Connect a document
      tags:
      - Documents
  /v1/documents/{documentId}/associations/{connectionId}:
    delete:
      description: "Removes one connection: it is kept as history with `detachedAt`\
        \ and `detachReason` `REMOVED`, and answered as it is now. The document is\
        \ untouched. Repeating it answers the same, with the first removal's time."
      operationId: unlinkDocument
      parameters:
      - in: path
        name: documentId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: connectionId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocumentAssociation"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'documentId'
                    error: validation_failed
                    parameter: documentId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:write
      summary: Remove a document's connection
      tags:
      - Documents
  /v1/documents/{documentId}/download-url:
    get:
      description: Returns a short-lived signed GET URL for the binary. Every issue
        is recorded in the document's access log.
      operationId: getDocumentDownloadUrl
      parameters:
      - in: path
        name: documentId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DownloadUrlResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'documentId'
                    error: validation_failed
                    parameter: documentId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'documents:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: documents:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - documents:read
      summary: Get a download URL
      tags:
      - Documents
  /v1/jobs:
    get:
      description: "The jobs this API client submitted, newest first, cursor-paginated.\
        \ Filter by status to find what is still pending or running; a job's import\
        \ is linked from the import itself, not from here."
      operationId: listJobs
      parameters:
      - description: Only jobs in this state (any case is accepted).
        in: query
        name: status
        required: false
        schema:
          type: string
          enum:
          - PENDING
          - RUNNING
          - SUCCEEDED
          - FAILED
          - EXPIRED
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageJobResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
      security:
      - oauth2: []
      summary: List your jobs
      tags:
      - Jobs
  /v1/jobs/{jobId}:
    get:
      description: "Visible only to the API client that submitted it. Poll until status\
        \ is succeeded, failed, or expired; job completion also produces a job.succeeded/job.failed\
        \ webhook event."
      operationId: getJob
      parameters:
      - in: path
        name: jobId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/JobResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'jobId'
                    error: validation_failed
                    parameter: jobId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
      security:
      - oauth2: []
      summary: Get a job's status
      tags:
      - Jobs
  /v1/organizations:
    get:
      description: "Your organization and every organization below it, cursor-paginated:\
        \ id, name and `parentId` (null at the top of your reach). Use `id` as `organizationId`\
        \ — for example to create the first company of an organization that has none\
        \ yet. Organizations that were terminated 90 days ago or more are not listed."
      operationId: listOrganizations
      parameters:
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageOrganizationResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
      security:
      - oauth2:
        - companies:read
      summary: List organizations
      tags:
      - Organizations
  /v1/organizations/{organizationId}/access-overview:
    get:
      description: "Who reaches what, and why, across the organization's own companies\
        \ (not those of the organizations below it): every company with how many people\
        \ reach it, per role; every person the organization's access touches (its\
        \ members, with access or not, the people its policies reach, and the organization\
        \ admins, of a parent organization too) with how many companies they reach,\
        \ their highest role, portfolios, groups and the time-bound auditor grants\
        \ in force; and the totals. The same resolution the access checks and `GET\
        \ /organizations/{organizationId}/users/{userId}/effective-access` use. People\
        \ are named; their e-mail addresses are read from the users endpoints."
      operationId: getAccessOverview
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccessOverviewResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'access:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: access:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - access:manage
      summary: Get the organization's access report
      tags:
      - Access Management
  /v1/organizations/{organizationId}/access-policies:
    get:
      description: "Always one page today (`hasMore` false, `nextCursor` null), but\
        \ follow `hasMore`: this list may page in a later release, and a client that\
        \ stops at the first page will then miss rows."
      operationId: listAccessPolicies
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageAccessPolicyResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'access:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: access:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - access:manage
      summary: List access policies
      tags:
      - Access Management
    post:
      description: "The policy is one document: name, description and its rules. A\
        \ rule grants a role on a company, a portfolio's companies or every company,\
        \ over every account (resourceScope ALL), the accounts of some templates (TEMPLATES,\
        \ templateTypes) or some account codes (ACCOUNTS, accountCodes, a company\
        \ rule only). It grants access only to the users and groups assigned to it;\
        \ isDefault true is refused (400, reason default_policy_retired)."
      operationId: createAccessPolicy
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePolicyRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccessPolicyResponse"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            Location:
              description: "The created resource, path-absolute: GET /v1/organizations/{organizationId}/access-policies/{id}.\
                \ Also on a replayed response."
              schema:
                type: string
                format: uri-reference
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'access:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: access:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                duplicate_name:
                  value:
                    detail: An active policy with this name already exists
                    error: duplicate_resource
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Duplicate Resource
                    type: https://api.accountflow.com/errors/duplicate-resource
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - access:manage
      summary: Create an access policy
      tags:
      - Access Management
  /v1/organizations/{organizationId}/access-policies/{policyId}:
    get:
      operationId: getAccessPolicy
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: policyId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccessPolicyResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'access:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: access:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - access:manage
      summary: Get one access policy
      tags:
      - Access Management
    patch:
      description: "Patch semantics for the scalar fields; a rules array, when present,\
        \ replaces the whole rule set: rules are matched on target and resourceScope,\
        \ so the rules read with the policy, sent back, change nothing. A rule states\
        \ its scopeType (COMPANY, PORTFOLIO, ORGANIZATION) or it is inferred from\
        \ its target; dropping a PORTFOLIO rule while sending an all-companies rule\
        \ without scopeType is refused with 409 (portfolio_rule_would_widen), and\
        \ dropping a TEMPLATES or ACCOUNTS rule while sending a rule for the same\
        \ target without resourceScope with 409 (restricted_rule_dropped). A policy\
        \ that backs an open time-bound grant keeps its rules (409, policy_backs_time_bound_grant).\
        \ Unknown fields are refused."
      operationId: updateAccessPolicy
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: policyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePolicyRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccessPolicyResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'access:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: access:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - access:manage
      summary: Update an access policy
      tags:
      - Access Management
  /v1/organizations/{organizationId}/access-policies/{policyId}/actions/archive:
    post:
      description: Archived policies grant nothing and stay for audit; they are never
        hard-deleted. Idempotent.
      operationId: archiveAccessPolicy
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: policyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccessPolicyResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'access:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: access:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - access:manage
      summary: Archive an access policy
      tags:
      - Access Management
  /v1/organizations/{organizationId}/access-policies/{policyId}/assignments:
    post:
      description: "The user's effective access becomes the union of the policies\
        \ assigned to them, directly or through a group. There is no organization\
        \ default policy: it is retired."
      operationId: assignAccess
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: policyId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AssignRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AssignmentResponse"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'access:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: access:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                already_assigned:
                  value:
                    detail: The user is already assigned to this policy
                    error: duplicate_resource
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Duplicate Resource
                    type: https://api.accountflow.com/errors/duplicate-resource
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - access:manage
      summary: Assign a user to a policy
      tags:
      - Access Management
  /v1/organizations/{organizationId}/access-policies/{policyId}/assignments/{userId}:
    delete:
      operationId: revokeAccess
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: policyId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: userId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccessRevocationResult"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'access:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: access:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - access:manage
      summary: Revoke a user's assignment
      tags:
      - Access Management
  /v1/organizations/{organizationId}/audit-events:
    get:
      description: "The audit log the app shows an organization admin, newest first\
        \ and cursor-paginated: access policies and their assignments, company and\
        \ account settings, approvals, comments, imports, each with who did it and\
        \ when. Only the organization named: each organization below it keeps its\
        \ own log. Filters compose; give `dateFrom` and `dateTo` when you can, since\
        \ the log is stored month by month. A client acting as a person needs that\
        \ person to be an organization admin; otherwise the log is a 404. E-mail addresses,\
        \ IP addresses and user agents are never returned, and an intercompany pair's\
        \ figures are withheld unless you can read the counterparty company."
      operationId: listAuditEvents
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Only events done to this kind of thing, e.g. ACCESS_POLICY or\
          \ COMPANY."
        in: query
        name: targetType
        required: false
        schema:
          type: string
      - description: Only events done to this thing (an event's targetId).
        in: query
        name: targetId
        required: false
        schema:
          type: string
          format: uuid
      - description: Only events this person did (an event's actor.userId).
        in: query
        name: actorUserId
        required: false
        schema:
          type: string
          format: uuid
      - description: "Only events whose action starts with this text, e.g. access_policy.\
          \ (taken literally)."
        in: query
        name: actionPrefix
        required: false
        schema:
          type: string
      - description: "First day of the range (inclusive), a Norwegian day, 2000-01-01\
          \ to 9999-12-31."
        in: query
        name: dateFrom
        required: false
        schema:
          type: string
          format: date
      - description: "Last day of the range (inclusive), a Norwegian day, 2000-01-01\
          \ to 9999-12-31."
        in: query
        name: dateTo
        required: false
        schema:
          type: string
          format: date
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageAuditEventResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'audit:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: audit:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - audit:read
      summary: List the organization's audit events
      tags:
      - Audit log
  /v1/organizations/{organizationId}/companies:
    post:
      description: "Registers a new accounting client under one of your organizations,\
        \ provisions its settings and first ledger, and grants access per the organization's\
        \ policies."
      operationId: createCompany
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCompanyRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyResponse"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            Location:
              description: "The created resource, path-absolute: GET /v1/companies/{id}.\
                \ Also on a replayed response."
              schema:
                type: string
                format: uri-reference
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:write' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:write
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                fiscal_year_overlap:
                  value:
                    accountingYear: 2026
                    detail: The fiscal year overlaps another fiscal year of the company;
                      a transition year (6 or 18 months) is not supported
                    error: conflict
                    reason: fiscal_year_overlap
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:write
      summary: Create a company
      tags:
      - Companies
  /v1/organizations/{organizationId}/tasks:
    get:
      description: "One list across the organization's own companies (not those of\
        \ the organizations below it), sorted as a company's list; `portfolioId` narrows\
        \ to one portfolio's companies. A company whose tasks you may not see is left\
        \ out, and an organization or portfolio outside your reach lists nothing."
      operationId: listOrganizationTasks
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - description: Only this portfolio's companies (from listPortfolios).
        in: query
        name: portfolioId
        required: false
        schema:
          type: string
          format: uuid
      - description: "Only tasks in these statuses (repeat the parameter or separate\
          \ with commas); default OPEN,BLOCKED."
        in: query
        name: status
        required: false
        schema:
          type: array
          items:
            type: string
            enum:
            - OPEN
            - BLOCKED
            - RESOLVED
            - WAIVED
            - SUPERSEDED
            - NOT_APPLICABLE
            - MANUAL_CLOSED
      - description: "Only this rule's tasks (rule.code, for example L01)."
        in: query
        name: rule
        required: false
        schema:
          type: string
      - description: "me, none (unassigned) or a user id."
        in: query
        name: assignee
        required: false
        schema:
          type: string
      - description: Also the tasks your linked person snoozed; default false.
        in: query
        name: includeSnoozed
        required: false
        schema:
          type: boolean
      - description: Also the tasks your linked person hid; default false.
        in: query
        name: includeHidden
        required: false
        schema:
          type: boolean
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageTaskResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List the tasks of an organization's companies
      tags:
      - Tasks
  /v1/organizations/{organizationId}/users:
    get:
      description: |-
        Members of the organization. Disabled users are listed with status DISABLED; deleted users are not represented.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listOrgUsers
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageUserResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'users:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: users:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - users:read
      summary: List the organization's users
      tags:
      - Users
  /v1/organizations/{organizationId}/users/{userId}:
    get:
      operationId: getUser
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: userId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'users:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: users:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - users:read
      summary: Get one user
      tags:
      - Users
  /v1/organizations/{organizationId}/users/{userId}/effective-access:
    get:
      description: |-
        The user's access per company as Accountflow resolves it: the highest role anywhere in the company, the role on every account (unrestrictedRole, null when every grant is restricted), the roles on templates and account codes above it, and every grant behind them (sources: a policy rule held directly or through a group, with a time-bound grant's window, or an organization admin's reach, ADMIN on every company). A time-bound grant counts only while in force. A user who is not a member of the organization is a 404.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: getEffectiveAccess
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: userId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageEffectiveAccessResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'users:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: users:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - users:read
      summary: Get one user's effective access
      tags:
      - Users
  /v1/organizations/{organizationId}/webhooks:
    get:
      description: "Always one page today (`hasMore` false, `nextCursor` null), but\
        \ follow `hasMore`: this list may page in a later release, and a client that\
        \ stops at the first page will then miss rows."
      operationId: listWebhookEndpoints
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageWebhookEndpointResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'webhooks:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: webhooks:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - webhooks:manage
      summary: List webhook endpoints
      tags:
      - Webhooks
    post:
      description: The response carries the signing secret EXACTLY ONCE. The endpoint
        starts in PENDING_VERIFICATION and must answer the verification challenge
        (a webhook.verification POST) with a 2xx whose body contains the hex HMAC-SHA256
        of the challenge under the signing secret before events flow.
      operationId: createWebhookEndpoint
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateWebhookRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookEndpointCreatedResponse"
          description: "Created. A retry with the same Idempotency-Key returns this\
            \ same response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            Location:
              description: "The created resource, path-absolute: GET /v1/organizations/{organizationId}/webhooks/{id}.\
                \ Also on a replayed response."
              schema:
                type: string
                format: uri-reference
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'webhooks:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: webhooks:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - webhooks:manage
      summary: Register a webhook endpoint
      tags:
      - Webhooks
  /v1/organizations/{organizationId}/webhooks/{webhookId}:
    delete:
      operationId: deleteWebhookEndpoint
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: webhookId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeletionResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'webhooks:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: webhooks:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - webhooks:manage
      summary: Delete a webhook endpoint
      tags:
      - Webhooks
    get:
      operationId: getWebhookEndpoint
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: webhookId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookEndpointResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'webhooks:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: webhooks:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - webhooks:manage
      summary: Get one webhook endpoint
      tags:
      - Webhooks
    patch:
      description: Patch semantics. Changing the URL puts the endpoint back into PENDING_VERIFICATION
        until the new URL answers the challenge.
      operationId: updateWebhookEndpoint
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: webhookId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateWebhookRequest"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookEndpointResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
                unreadable_body:
                  value:
                    detail: Failed to read request
                    error: validation_failed
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ the body is not valid JSON, names an unknown property or misses a required\
            \ one; a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'webhooks:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: webhooks:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                body_too_large:
                  value:
                    detail: The request body exceeds the limit of 8388608 bytes
                    error: payload_too_large
                    limit: 8388608
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 413
                    title: Payload Too Large
                    type: https://api.accountflow.com/errors/payload-too-large
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The request body exceeds 8 MiB, or a list exceeds its per-request\
            \ limit (`limit`). Split the data into several requests."
        "415":
          content:
            application/problem+json:
              examples:
                unsupported_media_type:
                  value:
                    detail: Unsupported Media Type
                    error: unsupported_media_type
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 415
                    supported:
                    - application/json
                    title: Unsupported Media Type
                    type: https://api.accountflow.com/errors/unsupported-media-type
              schema:
                $ref: "#/components/schemas/Problem"
          description: The Content-Type is not one this operation accepts (`supported`
            lists them).
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - webhooks:manage
      summary: Update a webhook endpoint
      tags:
      - Webhooks
  /v1/organizations/{organizationId}/webhooks/{webhookId}/actions/rotate-secret:
    post:
      description: Returns the NEW secret exactly once; old signatures stop validating
        immediately.
      operationId: rotateWebhookSecret
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: webhookId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Required on every mutation. A unique key per logical request\
          \ (a UUID is ideal); a retry with the same key and body within 24 hours\
          \ returns the original response with Idempotency-Replayed: true, the same\
          \ key with a different body is 422 idempotency_key_reused, and a missing\
          \ key is 400."
        in: header
        name: Idempotency-Key
        required: true
        schema:
          type: string
          maxLength: 200
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookEndpointCreatedResponse"
          description: "OK. A retry with the same Idempotency-Key returns this same\
            \ response with Idempotency-Replayed: true."
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            Idempotency-Replayed:
              $ref: "#/components/headers/Idempotency-Replayed"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                idempotency_key_missing:
                  value:
                    detail: The Idempotency-Key header is required on every mutation
                    error: idempotency_key_missing
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Idempotency Key Missing
                    type: https://api.accountflow.com/errors/idempotency-key-missing
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'organizationId'
                    error: validation_failed
                    parameter: organizationId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the Idempotency-Key header is missing (idempotency_key_missing);\
            \ a parameter is missing, cannot be parsed or is out of range (`parameter`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'webhooks:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: webhooks:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                company_read_only:
                  value:
                    detail: "This organization was terminated: its companies can be\
                      \ read, but no longer changed"
                    error: conflict
                    reason: company_read_only
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 409
                    title: Conflict
                    type: https://api.accountflow.com/errors/conflict
                idempotency_in_flight:
                  value:
                    detail: A request with this Idempotency-Key is still being processed
                    error: idempotency_in_flight
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 2
                    status: 409
                    title: Request In Flight
                    type: https://api.accountflow.com/errors/idempotency-in-flight
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Conflict: the request is fine, the state is not: the first\
            \ request with this Idempotency-Key is still running (idempotency_in_flight,\
            \ with Retry-After); the organization was terminated and its companies\
            \ are read-only (company_read_only). `reason` and the extensions say which;\
            \ the examples show this operation's cases."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "422":
          content:
            application/problem+json:
              examples:
                idempotency_key_reused:
                  value:
                    detail: This Idempotency-Key was already used with a different
                      request body
                    error: idempotency_key_reused
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 422
                    title: Idempotency Key Reused
                    type: https://api.accountflow.com/errors/idempotency-key-reused
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Well-formed but refused: the Idempotency-Key was reused with\
            \ a different body (idempotency_key_reused), or one of this operation's\
            \ rules failed; `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - webhooks:manage
      summary: Rotate the signing secret
      tags:
      - Webhooks
  /v1/organizations/{organizationId}/webhooks/{webhookId}/deliveries:
    get:
      description: "The self-debugging surface: every attempt with status code, error,\
        \ and payload, newest first, cursor-paginated."
      operationId: listWebhookDeliveries
      parameters:
      - in: path
        name: organizationId
        required: true
        schema:
          type: string
          format: uuid
      - in: path
        name: webhookId
        required: true
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageWebhookDeliveryResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'webhooks:manage' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: webhooks:manage
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - webhooks:manage
      summary: List delivery attempts
      tags:
      - Webhooks
  /v1/portfolios:
    get:
      description: "The portfolios within your reach, cursor-paginated, each with\
        \ the member companies you can read; a portfolio with none is not listed.\
        \ Use `id` as `portfolioId` on the portfolio reads. `organizationId` narrows\
        \ to that organization and the ones below it; an organization outside your\
        \ reach narrows to nothing."
      operationId: listPortfolios
      parameters:
      - description: Only this organization's portfolios and those below it (from
          listOrganizations).
        in: query
        name: organizationId
        required: false
        schema:
          type: string
          format: uuid
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PagePortfolioResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'companies:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: companies:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - companies:read
      summary: List portfolios
      tags:
      - Portfolios
  /v1/portfolios/{portfolioId}/account-status:
    get:
      description: |-
        Per member company: reconcilable accounts, reconciled accounts, reconciled percentage and open accounts for one period. period counts from each member's own fiscal-year start month; yearMonth reads one calendar month at each member's own period.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listPortfolioAccountStatus
      parameters:
      - description: "The portfolio's id, from listPortfolios."
        in: path
        name: portfolioId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Accounting year, e.g. 2026: the calendar year a member's fiscal\
          \ year starts in. Required; yearMonth takes precedence when given."
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY. It counts from each member's own fiscal-year\
          \ start month (period 1 of a July year is July), so on a portfolio whose\
          \ members start their years in different months one period names different\
          \ calendar months; send yearMonth to read one calendar month. Required;\
          \ yearMonth takes precedence when given."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: MONTHLY (default) | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY
          | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: "A calendar month (YYYY-MM) read at each member's own fiscal\
          \ year and period, in periodType's cadence; takes precedence over year and\
          \ period, which are still required (period is still checked against periodType).\
          \ A member whose fiscal years do not reach the month is left out."
        example: 2026-11
        in: query
        name: yearMonth
        required: false
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PagePortfolioAccountStatusResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'portfolioId'
                    error: validation_failed
                    parameter: portfolioId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Summarize reconciliation across a portfolio
      tags:
      - Close
  /v1/portfolios/{portfolioId}/close-status:
    get:
      description: |-
        Each member company's close percentage and close stages for one period, with the year and period it was read at. period counts from each member's own fiscal-year start month; yearMonth reads one calendar month at each member's own period.

        Always one page today (`hasMore` false, `nextCursor` null), but follow `hasMore`: this list may page in a later release, and a client that stops at the first page will then miss rows.
      operationId: listPortfolioCloseStatus
      parameters:
      - description: "The portfolio's id, from listPortfolios."
        in: path
        name: portfolioId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Accounting year, e.g. 2026: the calendar year a member's fiscal\
          \ year starts in. Required; yearMonth takes precedence when given."
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY. It counts from each member's own fiscal-year\
          \ start month (period 1 of a July year is July), so on a portfolio whose\
          \ members start their years in different months one period names different\
          \ calendar months; send yearMonth to read one calendar month. Required;\
          \ yearMonth takes precedence when given."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: MONTHLY (default) | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY
          | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: "A calendar month (YYYY-MM) read at each member's own fiscal\
          \ year and period, in periodType's cadence; takes precedence over year and\
          \ period, which are still required (period is still checked against periodType).\
          \ A member whose fiscal years do not reach the month is left out."
        example: 2026-11
        in: query
        name: yearMonth
        required: false
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageCloseStatusResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_parameter:
                  value:
                    detail: Invalid value for parameter 'portfolioId'
                    error: validation_failed
                    parameter: portfolioId
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); a parameter is missing, cannot be parsed or is out of range\
            \ (`parameter` names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: Get the month-close status across a portfolio
      tags:
      - Close
  /v1/portfolios/{portfolioId}/work-queue:
    get:
      description: "Close work of every member company for one period, most urgent\
        \ first. Items the calling person marked done or snoozed are left out unless\
        \ includeDismissed=true. period counts from each member's own fiscal-year\
        \ start month; yearMonth reads one calendar month at each member's own period."
      operationId: listPortfolioWorkQueue
      parameters:
      - description: "The portfolio's id, from listPortfolios."
        in: path
        name: portfolioId
        required: true
        schema:
          type: string
          format: uuid
      - description: "Accounting year, e.g. 2026: the calendar year a member's fiscal\
          \ year starts in. Required; yearMonth takes precedence when given."
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      - description: "Period of the accounting year in the cadence periodType names:\
          \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
          \ 1-2 for HALF_YEARLY, 1 for YEARLY. It counts from each member's own fiscal-year\
          \ start month (period 1 of a July year is July), so on a portfolio whose\
          \ members start their years in different months one period names different\
          \ calendar months; send yearMonth to read one calendar month. Required;\
          \ yearMonth takes precedence when given."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: MONTHLY (default) | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY
          | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
      - description: "A calendar month (YYYY-MM) read at each member's own fiscal\
          \ year and period, in periodType's cadence; takes precedence over year and\
          \ period, which are still required (period is still checked against periodType).\
          \ A member whose fiscal years do not reach the month is left out."
        example: 2026-11
        in: query
        name: yearMonth
        required: false
        schema:
          type: string
      - description: Also return items marked done or snoozed.
        in: query
        name: includeDismissed
        required: false
        schema:
          type: boolean
      - description: "The previous page's pagination.nextCursor. Opaque and signed:\
          \ it is bound to the caller and to the other filters, so change a filter\
          \ and start again from the first page. A tampered or foreign cursor is 400\
          \ invalid_cursor."
        in: query
        name: cursor
        required: false
        schema:
          type: string
      - description: "Rows per page, 1–200 (default 50); out of range is 400."
        in: query
        name: pageSize
        required: false
        schema:
          type: integer
          format: int32
          default: 50
          maximum: 200
          minimum: 1
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageWorkQueueItemResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
                invalid_cursor:
                  value:
                    detail: The cursor is not valid for this request
                    error: invalid_cursor
                    parameter: cursor
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Invalid Cursor
                    type: https://api.accountflow.com/errors/invalid-cursor
                page_size:
                  value:
                    detail: pageSize must be between 1 and 200
                    error: validation_failed
                    parameter: pageSize
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it); the cursor is tampered with, foreign or minted for other\
            \ filters (invalid_cursor); a parameter is missing, cannot be parsed or\
            \ is out of range (`parameter` names it). `detail` says what; fix the\
            \ request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
                insufficient_scope:
                  value:
                    detail: This operation requires the 'reconciliation:read' scope
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    requiredScope: reconciliation:read
                    status: 403
                    title: Insufficient Scope
                    type: https://api.accountflow.com/errors/insufficient-scope
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "404":
          content:
            application/problem+json:
              examples:
                resource_not_found:
                  value:
                    detail: Resource not found
                    error: resource_not_found
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 404
                    title: Resource Not Found
                    type: https://api.accountflow.com/errors/resource-not-found
              schema:
                $ref: "#/components/schemas/Problem"
          description: No such resource within your reach. Absence and lack of access
            are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
        "503":
          content:
            application/problem+json:
              examples:
                service_unavailable:
                  value:
                    detail: Authorization backend unavailable
                    error: service_unavailable
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 503
                    title: Service Unavailable
                    type: https://api.accountflow.com/errors/service-unavailable
              schema:
                $ref: "#/components/schemas/Problem"
          description: The authorization service (or another dependency the decision
            needs) is unavailable; the call was refused rather than allowed. Retry
            with backoff.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
      security:
      - oauth2:
        - reconciliation:read
      summary: List the close work queue across a portfolio
      tags:
      - Close
  /v1/whoami:
    get:
      description: "Returns the authenticated API client's identity, mode, and organization\
        \ scope. Use it to verify credentials before calling anything else."
      operationId: getCallerIdentity
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WhoamiResponse"
          description: OK.
          headers:
            Deprecation:
              $ref: "#/components/headers/Deprecation"
            RateLimit-Limit:
              $ref: "#/components/headers/RateLimit-Limit"
            RateLimit-Remaining:
              $ref: "#/components/headers/RateLimit-Remaining"
            Sunset:
              $ref: "#/components/headers/Sunset"
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
        "400":
          content:
            application/problem+json:
              examples:
                delegation_header:
                  $ref: "#/components/examples/DelegationHeaderRefused"
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Malformed request: a delegation header (X-Acting-User, X-Saga-Run,\
            \ X-Saga-Proposal) was sent by a client that does not delegate (`header`\
            \ names it). `detail` says what; fix the request."
        "401":
          content:
            application/problem+json:
              examples:
                unauthorized:
                  value:
                    detail: Authentication required
                    error: unauthorized
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 401
                    title: Unauthorized
                    type: https://api.accountflow.com/errors/unauthorized
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Missing or invalid bearer token. WWW-Authenticate distinguishes\
            \ only 'no token' from invalid_token; why a token is invalid goes to the\
            \ logs, not to the caller."
        "403":
          content:
            application/problem+json:
              examples:
                forbidden:
                  value:
                    detail: API client is not active
                    error: forbidden
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 403
                    title: Forbidden
                    type: https://api.accountflow.com/errors/forbidden
              schema:
                $ref: "#/components/schemas/Problem"
          description: "The API client is not active (forbidden), lacks the scope\
            \ this operation needs (insufficient_scope, with requiredScope), or its\
            \ mode cannot perform it (capability_denied). Never a tenancy answer:\
            \ that is 404."
        "429":
          content:
            application/problem+json:
              examples:
                rate_limited:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    retryAfterSeconds: 12
                    status: 429
                    title: Rate Limited
                    type: https://api.accountflow.com/errors/rate-limited
              schema:
                $ref: "#/components/schemas/Problem"
          description: Rate limited. Retry after the number of seconds in Retry-After;
            the RateLimit-* headers on every response show the remaining budget.
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "500":
          content:
            application/problem+json:
              examples:
                internal_error:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    status: 500
                    title: Internal Error
                    type: https://api.accountflow.com/errors/internal-error
              schema:
                $ref: "#/components/schemas/Problem"
          description: "Unexpected server error. Nothing about the request was wrong:\
            \ retry is safe, and mutations retried with the same Idempotency-Key are\
            \ deduplicated."
      summary: Who am I
      tags:
      - Identity
components:
  examples:
    DelegationHeaderRefused:
      value:
        detail: X-Acting-User is only accepted from delegating clients
        error: validation_failed
        header: X-Acting-User
        requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
        status: 400
        title: Validation Failed
        type: https://api.accountflow.com/errors/validation-failed
  headers:
    Deprecation:
      description: "Present only when the operation is deprecated: '@' followed by\
        \ the epoch second the deprecation took effect (RFC 9745). See the deprecation\
        \ policy."
      schema:
        type: string
    Idempotency-Replayed:
      description: Present (true) when this response is the stored result of an earlier
        request with the same Idempotency-Key.
      schema:
        type: string
        enum:
        - "true"
    RateLimit-Limit:
      description: The client's sustained budget per minute (per Bridge replica).
      schema:
        type: integer
        format: int32
    RateLimit-Remaining:
      description: Requests left in the current window (per Bridge replica).
      schema:
        type: integer
        format: int32
    Retry-After:
      description: Seconds to wait before retrying.
      schema:
        type: integer
        format: int32
    Sunset:
      description: "Present only when the operation is deprecated: the HTTP-date after\
        \ which it stops working (RFC 8594), at least 12 months after Deprecation."
      schema:
        type: string
    X-Request-Id:
      description: "The request's correlation id, generated unless the request carried\
        \ one. Quote it in support requests; problem documents repeat it as requestId."
      schema:
        type: string
  schemas:
    AccessOverviewCompany:
      type: object
      description: One company and who reaches it.
      properties:
        alerts:
          type: array
          description: "Facts worth an administrator's attention. NO_POLICY_ACCESS:\
            \ no policy reaches the company; only organization admins open it."
          items:
            type: string
            enum:
            - NO_POLICY_ACCESS
            x-extensible-enum: true
        companyId:
          type: string
          format: uuid
        companyName:
          type: string
          nullable: true
        portfolios:
          type: array
          description: The portfolios the company is in.
          items:
            $ref: "#/components/schemas/AccessOverviewPortfolio"
        roleCounts:
          $ref: "#/components/schemas/AccessOverviewRoleCounts"
        usersWithAccess:
          type: integer
          format: int32
          description: "People with any access to the company, organization admins\
            \ included."
      required:
      - alerts
      - companyId
      - portfolios
      - roleCounts
      - usersWithAccess
    AccessOverviewGroup:
      type: object
      description: "A group, by id and name."
      properties:
        groupId:
          type: string
          format: uuid
        groupName:
          type: string
          nullable: true
      required:
      - groupId
    AccessOverviewPortfolio:
      type: object
      description: "A portfolio, by id and name."
      properties:
        portfolioId:
          type: string
          format: uuid
        portfolioName:
          type: string
          nullable: true
      required:
      - portfolioId
    AccessOverviewResponse:
      type: object
      description: "Who reaches what in one organization, and why: every company with\
        \ who reaches it, every person with what they reach, and the organization's\
        \ totals. One resolution, the one the access checks use."
      properties:
        companies:
          type: array
          description: "Every company of the organization (not of the organizations\
            \ below it), by name."
          items:
            $ref: "#/components/schemas/AccessOverviewCompany"
        totals:
          $ref: "#/components/schemas/AccessOverviewTotals"
        users:
          type: array
          description: "Every person the organization's access touches, by name: its\
            \ members (with access or not), the people its policies reach, and the\
            \ organization admins, of a parent organization too."
          items:
            $ref: "#/components/schemas/AccessOverviewUser"
      required:
      - companies
      - totals
      - users
    AccessOverviewRoleCounts:
      type: object
      description: "People per role, each counted once at their highest."
      properties:
        accountant:
          type: integer
          format: int32
        admin:
          type: integer
          format: int32
        auditor:
          type: integer
          format: int32
        viewer:
          type: integer
          format: int32
      required:
      - accountant
      - admin
      - auditor
      - viewer
    AccessOverviewTimeBoundGrant:
      type: object
      description: A time-bound grant in force on one company.
      properties:
        companyId:
          type: string
          format: uuid
        role:
          type: string
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: AUDITOR
          x-extensible-enum: true
        validFrom:
          type: string
          format: date-time
          description: The grant's first moment (inclusive).
        validTo:
          type: string
          format: date-time
          description: "The grant's end (exclusive): the access stops then, by itself."
      required:
      - companyId
      - role
      - validFrom
      - validTo
    AccessOverviewTotals:
      type: object
      description: Totals across the organization.
      properties:
        activePolicies:
          type: integer
          format: int32
          description: The organization's active access policies.
        companies:
          type: integer
          format: int32
        users:
          type: integer
          format: int32
        usersWithoutAccess:
          type: integer
          format: int32
          description: People who reach no company.
      required:
      - activePolicies
      - companies
      - users
      - usersWithoutAccess
    AccessOverviewUser:
      type: object
      description: One person and what they reach.
      properties:
        alerts:
          type: array
          description: "Facts worth an administrator's attention. NO_ACCESS: the person\
            \ reaches no company."
          items:
            type: string
            enum:
            - NO_ACCESS
            x-extensible-enum: true
        companiesWithAccess:
          type: integer
          format: int32
          description: How many of the organization's companies the person reaches.
        displayName:
          type: string
          description: First and last name; null when neither is on record.
          nullable: true
        groups:
          type: array
          description: The groups whose policy assignments reach the person.
          items:
            $ref: "#/components/schemas/AccessOverviewGroup"
        highestRole:
          type: string
          description: The highest role the person holds on any company. Null when
            they reach none.
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          nullable: true
          x-extensible-enum: true
        organizationAdmin:
          type: boolean
          description: "True when the person reaches every company as an organization\
            \ admin (of this organization or a parent), not through a policy."
        policyCount:
          type: integer
          format: int32
          description: How many distinct policies reach the person.
        portfolios:
          type: array
          description: The portfolios the person reaches companies through.
          items:
            $ref: "#/components/schemas/AccessOverviewPortfolio"
        status:
          type: string
          description: "Lifecycle state. A DISABLED or DELETED person reaches nothing:\
            \ listed with no companies and NO_ACCESS, whatever policies or admin role\
            \ they still hold; null when Accountflow holds no profile for the id."
          enum:
          - ACTIVE
          - DISABLED
          - DELETED
          nullable: true
          x-extensible-enum: true
        timeBoundGrants:
          type: array
          description: "The person's time-bound grants in force (an auditor's access\
            \ to named companies): each ends by itself at validTo. An ended one grants\
            \ nothing and is not listed."
          items:
            $ref: "#/components/schemas/AccessOverviewTimeBoundGrant"
        userId:
          type: string
          format: uuid
          description: "The user's id, as list_org_users and get_effective_access\
            \ take it."
      required:
      - alerts
      - companiesWithAccess
      - groups
      - organizationAdmin
      - policyCount
      - portfolios
      - timeBoundGrants
      - userId
    AccessPolicyResponse:
      type: object
      description: "An access policy: a named set of company access rules, assignable\
        \ to users."
      properties:
        createdAt:
          type: string
          format: date-time
        description:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
          description: The policy's stable identifier.
        isDefault:
          type: boolean
          deprecated: true
          description: "Legacy flag, reported as stored: the organization default\
            \ policy is retired, so it grants nothing, and writes refuse true. A policy\
            \ reaches only the users and groups assigned to it."
        name:
          type: string
          example: Standard bookkeeper
        rules:
          type: array
          items:
            $ref: "#/components/schemas/Rule"
        status:
          type: string
          description: Archived policies grant nothing and are kept for audit.
          enum:
          - ACTIVE
          - ARCHIVED
          x-extensible-enum: true
      required:
      - createdAt
      - id
      - isDefault
      - name
      - rules
      - status
    AccessRevocationResult:
      type: object
      description: Confirmation of a revocation.
      properties:
        policyId:
          type: string
          format: uuid
        status:
          type: string
          enum:
          - REVOKED
          example: REVOKED
          x-extensible-enum: true
        userId:
          type: string
          format: uuid
      required:
      - policyId
      - status
      - userId
    AccountAccrualResponse:
      type: object
      description: An accrual (periodisering) with its recognition schedule and the
        lines it is built from.
      properties:
        accrualBasis:
          type: string
          nullable: true
        amount:
          type: number
          description: What the accrual recognizes in the requested period (0 when
            nothing).
        basisLineIds:
          type: array
          description: Ids of the GL lines the accrual is based on (role BASIS).
          items:
            type: string
            description: Ids of the GL lines the accrual is based on (role BASIS).
        comment:
          type: string
          nullable: true
        date:
          type: string
          format: date
          description: The accrual's document date.
        deferredRevenue:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        endPeriod:
          type: integer
          format: int32
        endPeriodYear:
          type: integer
          format: int32
        id:
          type: string
          format: uuid
          description: Accrual id.
        lines:
          type: array
          description: Every GL line linked to the accrual.
          items:
            $ref: "#/components/schemas/AccrualLine"
        origin:
          type: string
          description: "MANUAL, IMPORT, SUGGESTION_ACCEPTED or AUTO_CREATED."
          enum:
          - MANUAL
          - IMPORT
          - SUGGESTION_ACCEPTED
          - AUTO_CREATED
          nullable: true
          x-extensible-enum: true
        originConfidence:
          type: integer
          format: int32
          description: Engine score 0-100 behind an engine origin.
          nullable: true
        originDetail:
          type: object
          additionalProperties:
            type: object
            description: Engine evidence behind an engine origin.
          description: Engine evidence behind an engine origin.
        originReviewedAt:
          type: string
          format: date-time
          description: When a person confirmed an auto-created accrual; absent = not
            confirmed (or not auto-created).
          nullable: true
        reversed:
          type: boolean
        schedule:
          type: array
          description: "The recognition schedule, in period order."
          items:
            $ref: "#/components/schemas/AccrualScheduleSlice"
        startPeriod:
          type: integer
          format: int32
        startPeriodYear:
          type: integer
          format: int32
        status:
          type: string
          description: "The accrual's state; ACTIVE today, more values may come."
          enum:
          - ACTIVE
          example: ACTIVE
          x-extensible-enum: true
        totalAmount:
          type: number
          description: The whole accrual across every period.
      required:
      - amount
      - basisLineIds
      - date
      - endPeriod
      - endPeriodYear
      - id
      - lines
      - originDetail
      - reversed
      - schedule
      - startPeriod
      - startPeriodYear
      - status
      - totalAmount
    AccountActivityResponse:
      type: object
      description: "One event in an account's activity history (approvals, comments,\
        \ flags, settlements, ...)."
      properties:
        action:
          type: string
          description: Machine action key.
          example: workflow.comment.created
        actionLabel:
          type: string
          description: Human label as recorded.
          nullable: true
        actionLabelI18n:
          type: string
          description: The label's i18n key.
          nullable: true
        actor:
          $ref: "#/components/schemas/ActivityActor"
        after:
          type: object
          additionalProperties:
            type: object
            description: Registered fields after the change.
            nullable: true
          description: Registered fields after the change.
          nullable: true
        before:
          type: object
          additionalProperties:
            type: object
            description: Registered fields before the change.
            nullable: true
          description: Registered fields before the change.
          nullable: true
        correlationId:
          type: string
          format: uuid
          description: Groups events that belong to one operation.
          nullable: true
        id:
          type: string
          format: uuid
          description: Event id.
        metadata:
          type: object
          additionalProperties:
            type: object
            description: "Free-form context (period, amounts, the account, ...)."
            nullable: true
          description: "Free-form context (period, amounts, the account, ...)."
          nullable: true
        occurredAt:
          type: string
          format: date-time
          description: When it happened.
        source:
          type: string
          description: The service that recorded it.
          enum:
          - CORE
          - BRIDGE
          - INGEST
          - CAR
          example: CORE
          x-extensible-enum: true
        targetId:
          type: string
          format: uuid
          description: The id of the thing it was done to.
        targetLabel:
          type: string
          nullable: true
        targetType:
          type: string
          description: What kind of thing it was done to.
          enum:
          - ACCESS_POLICY
          - ACCESS_POLICY_ASSIGNMENT
          - ACCESS_POLICY_RULE
          - ACCOUNT
          - ACCRUAL
          - API_CLIENT
          - ATTACHMENT
          - BANK_ACCOUNT
          - BANK_TRANSACTION
          - CAR_RUN
          - COMPANY
          - DOCUMENT
          - DOCUMENTATION_REQUEST
          - GROUP
          - INTEGRATION_CREDENTIAL
          - INTERCOMPANY_DEFINITION
          - INTERCOMPANY_GROUP
          - OPENING_BALANCE
          - ORGANIZATION
          - PORTFOLIO
          - RECONCILIATION
          - RECONCILIATION_ADJUSTMENT
          - ROUTINE_DESCRIPTION
          - TASK
          - USER
          - WEBHOOK_ENDPOINT
          - WORKFLOW_APPROVAL
          - WORKFLOW_COMMENT
          - WORKFLOW_FLAG
          - WORKFLOW_MATCH
          example: WORKFLOW_COMMENT
          x-extensible-enum: true
      required:
      - action
      - actor
      - id
      - occurredAt
      - source
      - targetId
      - targetType
    AccountAutomationSettings:
      type: object
      properties:
        amountToleranceNok:
          type: number
          nullable: true
        autoApprove:
          type: boolean
          nullable: true
        autoPostOnHighConfidence:
          type: boolean
          nullable: true
        enabled:
          type: boolean
          nullable: true
        maxGroupSize:
          type: integer
          format: int32
          nullable: true
        minConfidenceScore:
          type: integer
          format: int32
          nullable: true
        requireExactCounterparty:
          type: boolean
          nullable: true
        secondPassEnabled:
          type: boolean
          nullable: true
        secondPassMaxOpenLines:
          type: integer
          format: int32
          nullable: true
        secondPassWindowDays:
          type: integer
          format: int32
          nullable: true
    AccountLine:
      type: object
      description: One account of the chart.
      properties:
        accountCategory:
          type: string
          example: Balance
          nullable: true
        accountCode:
          type: string
          description: The account number as the ledger knows it.
          example: "1920"
        accountDescription:
          type: string
          example: Bankinnskudd
          nullable: true
        currencyCode:
          type: string
          example: NOK
          nullable: true
        hidden:
          type: boolean
          description: Hide the account in the application. Omit to leave an existing
            account's flag unchanged.
          nullable: true
      required:
      - accountCode
    AccountMapping:
      type: object
      description: A company account's standard account after a change.
      properties:
        accountId:
          type: string
          format: uuid
        accountNumber:
          type: string
          example: "1920"
        companyId:
          type: string
          format: uuid
        documentationRequired:
          type: boolean
        settingsRevision:
          type: integer
          format: int64
          description: Pass it back as settingsRevision to change the account again.
        standardAccount:
          $ref: "#/components/schemas/StandardAccount"
        templateEntryId:
          type: string
          format: uuid
          description: The account template's entry the account's values came from;
            absent when none.
          nullable: true
        templateType:
          type: string
          enum:
          - GENERAL_LEDGER_BALANCE
          - GENERAL_LEDGER_BALANCE_PRO
          - GENERAL_LEDGER
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - ACCRUALS
          - VAT
          - PAYROLL
          - ASSETS
          nullable: true
          x-extensible-enum: true
        templateValuesKept:
          type: array
          description: Template values left as they were because the company changed
            them.
          items:
            type: string
        templateValuesWritten:
          type: array
          description: Template values this change wrote.
          items:
            type: string
        year:
          type: integer
          format: int32
      required:
      - accountId
      - accountNumber
      - companyId
      - documentationRequired
      - settingsRevision
      - templateValuesKept
      - templateValuesWritten
      - year
    AccountMappingResult:
      type: object
      properties:
        accountId:
          type: string
          format: uuid
          nullable: true
        message:
          type: string
          nullable: true
        standardAccountId:
          type: string
          format: uuid
          nullable: true
        status:
          type: string
          enum:
          - MAPPED
          - FAILED
          x-extensible-enum: true
      required:
      - status
    AccountMappingRow:
      type: object
      properties:
        accountId:
          type: string
          format: uuid
        settingsRevision:
          type: integer
          format: int64
          description: "When given, the row fails if the account moved past it."
          nullable: true
        standardAccountId:
          type: string
          format: uuid
      required:
      - accountId
      - standardAccountId
    AccountOpeningBalanceResponse:
      type: object
      description: One line behind an account's opening balance (inngående balanse).
      properties:
        accountName:
          type: string
          nullable: true
        accountNumber:
          type: string
          example: "1500"
        amount:
          type: number
          description: Display amount in the base currency (an aggregate's residual).
        bankReconciliationStatus:
          type: string
          description: "The state of that group: RECONCILED, or STALE when it needs\
            \ review. Null when no bank group holds the row."
          enum:
          - RECONCILED
          - STALE
          nullable: true
          x-extensible-enum: true
        baseCurrency:
          type: string
          nullable: true
        date:
          type: string
          format: date
          description: "The balance's date: the fiscal-year start."
          nullable: true
        description:
          type: string
          nullable: true
        dimensionKeys:
          type: array
          description: Dimension keys the balance is tagged with.
          items:
            type: string
            description: Dimension keys the balance is tagged with.
        exchangeRate:
          type: number
          nullable: true
        hasChildren:
          type: boolean
          description: True for an aggregate with specified items — its amount is
            the unspecified residual.
        openItem:
          $ref: "#/components/schemas/OpeningBalanceOpenItem"
        openingBalanceId:
          type: string
          description: "The opening balance's stable id: what list_comments' and list_flags'\
            \ openingBalanceId take."
        origin:
          type: string
          description: "ERP (imported), SPLIT (an item specified in the app) or MANUAL\
            \ (imported item)."
          example: ERP
        parentOpeningBalanceId:
          type: string
          description: The openingBalanceId of the aggregate this item specifies;
            absent for an aggregate or plain line.
          nullable: true
        partyKeys:
          type: array
          description: "The parties (customers, suppliers) the balance is tagged with:\
            \ their partyKey, as list_sub_ledgers and list_open_items name them."
          items:
            type: string
            description: "The parties (customers, suppliers) the balance is tagged\
              \ with: their partyKey, as list_sub_ledgers and list_open_items name\
              \ them."
        reconciliationGroupId:
          type: string
          format: uuid
          description: "The bank reconciliation group holding the row (get_reconciliation's\
            \ reconciliationGroupId), when one does; a row a bank group holds is not\
            \ open, and create_settlement refuses it."
          nullable: true
        settlementId:
          type: string
          format: uuid
          description: "The newest settlement the balance is in, when it is in one."
          nullable: true
        settlementStatus:
          type: string
          description: "Ledger settlement (utligning) state only: OPEN, SETTLED or\
            \ PARTIAL (as for general-ledger lines). On a bank account a row can instead\
            \ be closed by a bank reconciliation group: read bankReconciliationStatus,\
            \ since a row is settled in one place only."
          enum:
          - OPEN
          - SETTLED
          - PARTIAL
          x-extensible-enum: true
        settlementType:
          type: string
          enum:
          - AUTO
          - MANUAL
          nullable: true
          x-extensible-enum: true
        sourceAmount:
          type: number
          description: The amount as imported.
        specifiedAmount:
          type: number
          description: How much of an aggregate its items specify (0 without items).
        transactionAmount:
          type: number
          nullable: true
        transactionCurrency:
          type: string
          nullable: true
        voucherDate:
          type: string
          format: date
          description: "The date of the original entry the row stands for (an outstanding\
            \ cheque, a deposit in transit), given when the item was specified in\
            \ the app; on or before the opening-balance date. Null when none was given.\
            \ It describes the entry only: the row stays in the opening balance, and\
            \ date stays the fiscal-year start."
          nullable: true
        voucherNo:
          type: string
          description: "The voucher (bilag) number of that original entry, as the\
            \ person who specified the item entered it; null when none was given.\
            \ Not checked against the ledger and not unique: pass it as list_general_ledger_lines'\
            \ voucherNo to look for that voucher."
          nullable: true
        year:
          type: integer
          format: int32
          description: The accounting year the balance is carried into.
      required:
      - accountNumber
      - amount
      - dimensionKeys
      - hasChildren
      - openingBalanceId
      - origin
      - partyKeys
      - settlementStatus
      - sourceAmount
      - specifiedAmount
      - year
    AccountReconciliationResponse:
      type: object
      description: One account's reconciliation for one period.
      properties:
        accountId:
          type: string
          format: uuid
        accountName:
          type: string
          nullable: true
        accountNumber:
          type: string
        adjustments:
          type: array
          description: "Manual reconciliation adjustment lines (explanations of a\
            \ deviation), newest first."
          items:
            $ref: "#/components/schemas/Adjustment"
        adjustmentsTotal:
          type: number
          description: Sum of the adjustment lines.
        approval:
          $ref: "#/components/schemas/ApprovalSummary"
        approvedBalance:
          type: number
          description: The balance the approval was taken against.
          nullable: true
        balance:
          type: number
          description: Outgoing (closing) balance of the period.
        commentCount:
          type: integer
          format: int32
          description: Comments on the account for the period.
        companyId:
          type: string
          format: uuid
        coverage:
          $ref: "#/components/schemas/Coverage"
        currency:
          type: string
          description: "ISO 4217 code of the amounts: the company's base currency\
            \ in the accounting year; null when none is recorded."
          nullable: true
        deviation:
          type: number
          description: balance minus the approved figure it is compared with; null
            when not approved.
          nullable: true
        linkedDependencyChanges:
          type: array
          items:
            $ref: "#/components/schemas/LinkedDependencyChange"
          nullable: true
        openingBalance:
          type: number
          nullable: true
        period:
          type: integer
          format: int32
          description: "The account's own period the requested period falls in, in\
            \ its cadence."
        periodMovement:
          type: number
          nullable: true
        readiness:
          $ref: "#/components/schemas/Readiness"
        reconciledAmount:
          type: number
          description: The approved (reconciled) amount; null when not approved.
          nullable: true
        reconciliationFrequency:
          type: string
          description: The account's own reconciliation cadence.
        stale:
          type: boolean
        staleReasons:
          type: array
          items:
            type: string
        status:
          type: string
          description: "RECONCILED, DEVIATION, AWAITING_CONTROL, STALE, READY_FOR_APPROVAL,\
            \ OPEN or FUTURE — as in the account status list. More values may be added."
          enum:
          - RECONCILED
          - DEVIATION
          - AWAITING_CONTROL
          - STALE
          - READY_FOR_APPROVAL
          - OPEN
          - FUTURE
          x-extensible-enum: true
        templateType:
          type: string
          enum:
          - GENERAL_LEDGER_BALANCE
          - GENERAL_LEDGER_BALANCE_PRO
          - GENERAL_LEDGER
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - ACCRUALS
          - VAT
          - PAYROLL
          - ASSETS
          x-extensible-enum: true
        year:
          type: integer
          format: int32
        yearOpeningBalance:
          type: number
          nullable: true
      required:
      - accountId
      - accountNumber
      - adjustments
      - adjustmentsTotal
      - approval
      - balance
      - commentCount
      - companyId
      - coverage
      - period
      - readiness
      - reconciliationFrequency
      - stale
      - staleReasons
      - status
      - templateType
      - year
    AccountSettings:
      type: object
      description: One account's settings.
      properties:
        accountId:
          type: string
          format: uuid
          description: The account (core's account map id).
        accountName:
          type: string
          nullable: true
        accountNumber:
          type: string
          example: "1920"
        automation:
          $ref: "#/components/schemas/AccountAutomationSettings"
        balanceRecon:
          $ref: "#/components/schemas/BalanceReconRule"
        companyId:
          type: string
          format: uuid
        documentationRequired:
          type: boolean
          description: Whether every posting needs documentation; null follows the
            standard account.
          nullable: true
        hidden:
          type: boolean
          description: Hidden from the account lists.
        matchRules:
          $ref: "#/components/schemas/MatchRules"
        matchWindowDays:
          type: integer
          format: int32
          description: "First-pass match window in days; null inherits. A general\
            \ ledger account's is set here; a BANK account's is its exact-match window,\
            \ set with its bank match settings. Applies whatever overrideCompanyDefaults\
            \ says."
          nullable: true
        overrideCompanyDefaults:
          type: boolean
          description: Whether the automation values below override the module and
            company defaults; matchWindowDays and maxGroupSize apply either way.
        owner:
          $ref: "#/components/schemas/PersonRef"
        settingsRevision:
          type: integer
          format: int64
          description: Pass it back as settingsRevision to change these settings.
        standardAccount:
          $ref: "#/components/schemas/AccountStandardAccount"
        subledgerRecon:
          $ref: "#/components/schemas/SubledgerReconRule"
        templateType:
          type: string
          description: How the account is reconciled.
          enum:
          - GENERAL_LEDGER_BALANCE
          - GENERAL_LEDGER_BALANCE_PRO
          - GENERAL_LEDGER
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - ACCRUALS
          - VAT
          - PAYROLL
          - ASSETS
          nullable: true
          x-extensible-enum: true
        year:
          type: integer
          format: int32
          description: The accounting year the account belongs to.
      required:
      - accountId
      - accountNumber
      - automation
      - companyId
      - hidden
      - overrideCompanyDefaults
      - settingsRevision
      - year
    AccountStandardAccount:
      type: object
      description: The standard account it is mapped to; absent when unmapped.
      nullable: true
      properties:
        description:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
        number:
          type: string
          example: "1920"
      required:
      - id
      - number
    AccountStatusResponse:
      type: object
      description: One account's reconciliation status for a period.
      properties:
        accountId:
          type: string
          format: uuid
        accountName:
          type: string
          nullable: true
        accountNumber:
          type: string
        approval:
          $ref: "#/components/schemas/ApprovalSummary"
        approvedBalance:
          type: number
          description: The balance the approval was taken against.
          nullable: true
        balance:
          type: number
          description: Outgoing (closing) balance of the period; null for templates
            reconciled elsewhere.
          nullable: true
        currency:
          type: string
          description: "ISO 4217 code of the amounts: the company's base currency\
            \ in the accounting year; null when none is recorded."
          nullable: true
        deviation:
          type: number
          description: "balance minus the approved figure it is compared with (the\
            \ captured balance for a linked approval, the reconciled amount otherwise);\
            \ null when either is unknown."
          nullable: true
        hasComments:
          type: boolean
          description: The account has comments for the period.
        linkedDependencyChanges:
          type: array
          description: "A stale linked approval: the dependencies whose balances moved."
          items:
            $ref: "#/components/schemas/LinkedDependencyChange"
          nullable: true
        openingBalance:
          type: number
          description: Balance incoming to the period.
          nullable: true
        period:
          type: integer
          format: int32
          description: "The account's own period the requested period falls in, in\
            \ its cadence."
          nullable: true
        periodMovement:
          type: number
          nullable: true
        postsSettled:
          type: integer
          format: int64
          description: "Of those, lines settled (or periodised on an ACCRUALS account)."
          nullable: true
        postsTotal:
          type: integer
          format: int64
          description: GL lines in the period's cumulative balance.
          nullable: true
        reconciledAmount:
          type: number
          description: The approved (reconciled) amount; null when not approved.
          nullable: true
        reconciliationFrequency:
          type: string
          description: "The account's own reconciliation cadence (MONTHLY, QUARTERLY,\
            \ …)."
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          nullable: true
          x-extensible-enum: true
        stale:
          type: boolean
        staleReasons:
          type: array
          description: "One code per drifted fact, e.g. BALANCE_CHANGED, PERIOD_MOVEMENT_CHANGED,\
            \ PERIOD_TYPE_CHANGED, CURRENCY_BALANCE_CHANGED, RULE_SET_CHANGED."
          items:
            type: string
            description: "One code per drifted fact, e.g. BALANCE_CHANGED, PERIOD_MOVEMENT_CHANGED,\
              \ PERIOD_TYPE_CHANGED, CURRENCY_BALANCE_CHANGED, RULE_SET_CHANGED."
        status:
          type: string
          description: "RECONCILED (approved, no deviation), DEVIATION (approved,\
            \ balance differs), AWAITING_CONTROL (approved, but the approval policy\
            \ still asks for a control by another person; not reconciled yet), STALE\
            \ (approved, but evidence changed since), READY_FOR_APPROVAL (not approved,\
            \ but the latest automation run proved this balance and left the approval\
            \ to a person), OPEN (not approved), FUTURE (the period has not started),\
            \ NOT_APPLICABLE (reconciled on its own page: VAT, payroll, assets). More\
            \ values may be added."
          enum:
          - RECONCILED
          - DEVIATION
          - AWAITING_CONTROL
          - STALE
          - READY_FOR_APPROVAL
          - OPEN
          - FUTURE
          - NOT_APPLICABLE
          x-extensible-enum: true
        templateType:
          type: string
          description: "The account's reconciliation template, e.g. BANK, GENERAL_LEDGER_BALANCE,\
            \ ACCRUALS."
          enum:
          - GENERAL_LEDGER_BALANCE
          - GENERAL_LEDGER_BALANCE_PRO
          - GENERAL_LEDGER
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - ACCRUALS
          - VAT
          - PAYROLL
          - ASSETS
          nullable: true
          x-extensible-enum: true
        year:
          type: integer
          format: int32
        yearOpeningBalance:
          type: number
          description: The accounting year's opening balance.
          nullable: true
      required:
      - accountId
      - accountNumber
      - approval
      - hasComments
      - stale
      - staleReasons
      - status
      - year
    AccountTemplateAccountChanges:
      type: object
      properties:
        accountId:
          type: string
          format: uuid
        accountName:
          type: string
          nullable: true
        accountNumber:
          type: string
          example: "1920"
        changes:
          type: array
          items:
            $ref: "#/components/schemas/AccountTemplateFieldChange"
        entryId:
          type: string
          format: uuid
        standardAccountNumber:
          type: string
        year:
          type: integer
          format: int32
      required:
      - accountId
      - accountNumber
      - changes
      - entryId
      - standardAccountNumber
      - year
    AccountTemplateApplied:
      type: object
      properties:
        accountTemplateId:
          type: string
          format: uuid
        accountsChanged:
          type: integer
          format: int64
        accountsCovered:
          type: integer
          format: int64
        companyId:
          type: string
          format: uuid
      required:
      - accountTemplateId
      - accountsChanged
      - accountsCovered
      - companyId
    AccountTemplateApplyPreview:
      type: object
      properties:
        accountTemplateId:
          type: string
          format: uuid
        accounts:
          type: array
          description: "Accounts that would change, and how."
          items:
            $ref: "#/components/schemas/AccountTemplateAccountChanges"
        accountsCovered:
          type: integer
          format: int64
          description: Mapped accounts the template has an entry for.
        accountsNotCovered:
          type: integer
          format: int64
          description: Mapped accounts it has none for; they are left as they are.
        companyId:
          type: string
          format: uuid
        entryRevisions:
          type: object
          additionalProperties:
            type: integer
            format: int64
            description: "Pass back to apply: the entries as the preview read them."
          description: "Pass back to apply: the entries as the preview read them."
        name:
          type: string
        warnings:
          type: array
          description: Changes that weaken a control; pass them back as confirmedWarnings
            to apply.
          items:
            type: string
            enum:
            - DOCUMENTATION_REQUIREMENT_REMOVED
            - TEMPLATE_CHANGED
            - AUTO_APPROVE_ENABLED
            x-extensible-enum: true
      required:
      - accountTemplateId
      - accounts
      - accountsCovered
      - accountsNotCovered
      - companyId
      - entryRevisions
      - name
      - warnings
    AccountTemplateFieldChange:
      type: object
      properties:
        after:
          type: object
          description: The template's value.
          nullable: true
        before:
          type: object
          description: "The account's value now, in core's stored settings shape (normalized:\
            \ numbers as strings), except that an estimate flag's account is accountNumber,\
            \ as in update_account_settings."
          nullable: true
        field:
          type: string
          description: "template_type, is_documentation_required, balance_recon, subledger_recon,\
            \ automation or match_rules."
          enum:
          - template_type
          - is_documentation_required
          - balance_recon
          - subledger_recon
          - automation
          - match_rules
          x-extensible-enum: true
      required:
      - field
    AccountTemplateFieldState:
      type: object
      properties:
        changedLocally:
          type: boolean
          description: Whether the company changed it since the template gave it.
        field:
          type: string
        templateValue:
          type: object
          description: The template's value now.
          nullable: true
      required:
      - changedLocally
      - field
    AccountTemplateProvenance:
      type: object
      properties:
        accountId:
          type: string
          format: uuid
        accountTemplateId:
          type: string
          format: uuid
          nullable: true
        companyId:
          type: string
          format: uuid
        currentRevision:
          type: integer
          format: int64
          description: The entry's revision now; absent when the entry no longer describes
            it.
          nullable: true
        entryId:
          type: string
          format: uuid
          description: The entry the values came from; absent when none did.
          nullable: true
        fields:
          type: array
          items:
            $ref: "#/components/schemas/AccountTemplateFieldState"
        receivedRevision:
          type: integer
          format: int64
          description: The entry's revision the account received.
          nullable: true
        settingsRevision:
          type: integer
          format: int64
        templateName:
          type: string
          nullable: true
      required:
      - accountId
      - companyId
      - fields
      - settingsRevision
    AccountTemplateRef:
      type: object
      description: "The organization's templates, the default first."
      properties:
        id:
          type: string
          format: uuid
        isDefault:
          type: boolean
        name:
          type: string
      required:
      - id
      - isDefault
      - name
    AccountsImportRequest:
      type: object
      properties:
        accounts:
          type: array
          items:
            $ref: "#/components/schemas/AccountLine"
        year:
          type: integer
          format: int32
      required:
      - accounts
      - year
    AccrualLine:
      type: object
      description: A general-ledger line linked to an accrual.
      properties:
        accountNumber:
          type: string
          nullable: true
        amount:
          type: number
          nullable: true
        lineId:
          type: string
        period:
          type: integer
          format: int32
          nullable: true
        role:
          type: string
          description: "BASIS, RECOGNITION or ADJUSTMENT."
          enum:
          - BASIS
          - RECOGNITION
          - ADJUSTMENT
          x-extensible-enum: true
        text:
          type: string
          nullable: true
        transactionDate:
          type: string
          format: date
          nullable: true
        vatCode:
          type: string
          nullable: true
        voucherNo:
          type: string
          description: Voucher (bilag) number.
          nullable: true
        year:
          type: integer
          format: int32
          nullable: true
      required:
      - lineId
      - role
    AccrualScheduleSlice:
      type: object
      description: One base period of an accrual's recognition schedule.
      properties:
        amount:
          type: number
        period:
          type: integer
          format: int32
        recognitionLineId:
          type: string
          description: The GL line that recognized the slice.
          nullable: true
        status:
          type: string
          description: "PLANNED until a GL line recognizes the slice, then RECOGNIZED."
          enum:
          - PLANNED
          - RECOGNIZED
          x-extensible-enum: true
        year:
          type: integer
          format: int32
      required:
      - amount
      - period
      - status
      - year
    AccrualSuggestionResponse:
      type: object
      description: "A pending accrual suggestion: a series of GL lines the accrual\
        \ engine believes should be accrued over several periods. Accepting creates\
        \ exactly the schedule shown."
      properties:
        accountNumber:
          type: string
          description: The accruals account the suggestion is for.
          example: "1740"
        description:
          type: string
          description: Proposed description.
          nullable: true
        endPeriod:
          type: integer
          format: int32
          description: Last period.
        endPeriodYear:
          type: integer
          format: int32
          description: Last period's fiscal year.
        estimatedTerm:
          type: integer
          format: int32
          description: Estimated term in periods.
        id:
          type: string
          format: uuid
          description: Suggestion id.
        lineIds:
          type: array
          description: The GL line ids the series claims.
          items:
            type: string
            description: The GL line ids the series claims.
        lines:
          type: array
          description: "The claimed GL lines, as the engine described them."
          items:
            $ref: "#/components/schemas/Line"
        matcher:
          type: string
          description: AMOUNT_SERIES | DESCRIPTION_SERIES | VOUCHER_GROUP | AMOUNT_PAIR.
          enum:
          - AMOUNT_SERIES
          - DESCRIPTION_SERIES
          - VOUCHER_GROUP
          - AMOUNT_PAIR
          x-extensible-enum: true
        periods:
          type: array
          description: The schedule accepting would create.
          items:
            $ref: "#/components/schemas/Period"
        score:
          type: integer
          format: int32
          description: Confidence 0–100.
        scoreDetail:
          type: object
          additionalProperties:
            type: object
            description: "The score's components, as the engine reported them."
          description: "The score's components, as the engine reported them."
        startPeriod:
          type: integer
          format: int32
          description: First period.
        startPeriodYear:
          type: integer
          format: int32
          description: First period's fiscal year.
        suggestionKey:
          type: string
          description: The engine's stable key for the series.
        totalAmount:
          type: number
          description: The total to accrue.
      required:
      - accountNumber
      - endPeriod
      - endPeriodYear
      - estimatedTerm
      - id
      - lineIds
      - lines
      - matcher
      - periods
      - score
      - scoreDetail
      - startPeriod
      - startPeriodYear
      - suggestionKey
      - totalAmount
    ActivityActor:
      type: object
      description: The actor of an activity event.
      properties:
        displayName:
          type: string
          description: Name as shown in the app (or the integration's name).
          nullable: true
        role:
          type: string
          nullable: true
        source:
          type: string
          description: "USER, SYSTEM, INTEGRATION or SUPPORT."
          enum:
          - USER
          - SYSTEM
          - INTEGRATION
          - SUPPORT
          x-extensible-enum: true
        userId:
          type: string
          format: uuid
          description: The person's user id; absent for system actors.
          nullable: true
      required:
      - source
    AddIntercompanyLineRequest:
      type: object
      properties:
        expectedVersion:
          type: string
          description: The version the read returned (the groups' for a new link);
            refused with 409 if it changed since.
          maxLength: 64
          nullable: true
        lineType:
          type: string
          description: "OPERATING, LOAN, INTEREST, GROUP_CONTRIBUTION, DIVIDEND or\
            \ OTHER."
        name:
          type: string
          maxLength: 200
          nullable: true
        pairingKey:
          type: string
          format: uuid
          nullable: true
        sortOrder:
          type: integer
          format: int32
          minimum: 0
          nullable: true
      required:
      - lineType
    Adjustment:
      type: object
      description: "Manual reconciliation adjustment lines (explanations of a deviation),\
        \ newest first."
      properties:
        amount:
          type: number
        createdAt:
          type: string
          format: date-time
        createdBy:
          type: string
          format: uuid
          nullable: true
        createdByName:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
          description: The adjustment's id (delete_reconciliation_adjustment's adjustmentId).
      required:
      - amount
      - createdAt
      - id
    AgingBucketTotal:
      type: object
      description: Totals for one aging bucket and currency.
      properties:
        agingBucket:
          type: string
          description: The aging bucket.
          enum:
          - NO_DUE_DATE
          - NOT_DUE
          - 0-30
          - 31-60
          - 61-90
          - 91+
          x-extensible-enum: true
        amountOpen:
          type: number
          description: Open amount as of asOfDate.
        currency:
          type: string
          description: The currency of amountOpen.
          example: NOK
          nullable: true
        itemCount:
          type: integer
          format: int64
          description: Items in the bucket.
        maxDaysOverdue:
          type: integer
          format: int32
          description: Days past due of the most overdue open item; 0 when none is
            overdue.
        openItemCount:
          type: integer
          format: int64
          description: Items still open as of asOfDate.
        overdueItemCount:
          type: integer
          format: int64
          description: Open items past their due date.
      required:
      - agingBucket
      - amountOpen
      - itemCount
      - maxDaysOverdue
      - openItemCount
      - overdueItemCount
    ApplyAccountTemplateRequest:
      type: object
      properties:
        confirmedWarnings:
          type: array
          description: "The preview's warnings, confirmed."
          items:
            type: string
            description: "The preview's warnings, confirmed."
          nullable: true
        entryRevisions:
          type: object
          additionalProperties:
            type: integer
            format: int64
            description: entryRevisions from the preview.
          description: entryRevisions from the preview.
      required:
      - entryRevisions
    ApprovalFigures:
      type: object
      description: "A GL account period's balances and open lines, by the bank approval's\
        \ rules. Amounts are rounded to two decimals, in currencyCode."
      properties:
        accountPeriod:
          type: integer
          format: int32
          description: "The account period, in its own period type, as the approval\
            \ judges it."
          example: 3
        accountPeriodType:
          type: string
          description: The account's period type.
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          example: MONTHLY
          x-extensible-enum: true
        bankClosing:
          type: number
          description: "The bank's balance on periodEnd: for each bank account feeding\
            \ the GL account then, today's booked balance less everything dated after\
            \ it (typed lines left out). Null when such an account has no booked balance,\
            \ or the bank and ledger currencies differ."
          nullable: true
        bankNotInGl:
          type: number
          description: "Bank lines still open on periodEnd, by the same rule."
        currencyCode:
          type: string
          description: "The currency the amounts are in: a foreign-currency bank account's\
            \ own currency when the GL account is matched in it, else null for the\
            \ company's base currency."
          nullable: true
        deviation:
          type: number
          description: "glClosing - bankClosing - glNotInBank + bankNotInGl: what\
            \ the open lines do not explain. Null when either balance is."
          nullable: true
        glAccountNumber:
          type: string
          description: The GL account the figures are for (the bank account's mapping).
        glClosing:
          type: number
          description: The ledger's closing balance on periodEnd. Null in a foreign
            currency whose opening balance states no amount in it.
          nullable: true
        glNotInBank:
          type: number
          description: "Ledger posts still open on periodEnd: in no bank group, or\
            \ in a group with a line after periodEnd."
        periodEnd:
          type: string
          format: date
          description: The account period's last day.
        previousYearUnmatchedBankCount:
          type: integer
          format: int32
          description: Last year's bank lines still in no group that no person's approval
            of the year lists; any one holds the period.
        readThrough:
          type: boolean
          description: Every feeding bank account has been read through periodEnd
            (or through the day it stopped feeding). Null when no bank account feeds
            the GL account.
          nullable: true
        staleGroupCount:
          type: integer
          format: int32
          description: Stale bank groups holding a line of the period's scope.
        unmatchedBankCount:
          type: integer
          format: int32
          description: The year's bank lines up to periodEnd in no bank group.
        unmatchedGlCount:
          type: integer
          format: int32
          description: The year's ledger posts up to the period in no bank group.
      required:
      - accountPeriod
      - accountPeriodType
      - bankNotInGl
      - glAccountNumber
      - glNotInBank
      - periodEnd
      - previousYearUnmatchedBankCount
      - staleGroupCount
      - unmatchedBankCount
      - unmatchedGlCount
    ApprovalResponse:
      type: object
      description: "One reconciliation approval of an account, standing or revoked."
      properties:
        accountId:
          type: string
          format: uuid
          description: "The account's id in the approval's accounting year, when it\
            \ resolves."
          nullable: true
        accountNumber:
          type: string
        approvalId:
          type: string
          format: uuid
        approvalType:
          type: string
          enum:
          - GL_BALANCE_RECON
          - ACCRUALS_RECON
          x-extensible-enum: true
        approvedAmount:
          type: number
          description: The amount the approval reconciled to.
          nullable: true
        approvedAt:
          type: string
          format: date-time
        approvedAutomatically:
          type: boolean
        approvedBalance:
          type: number
          description: The balance captured when approving.
          nullable: true
        approvedBy:
          type: string
          format: uuid
          nullable: true
        approvedByKind:
          type: string
          description: "USER (a person), POLICY (the reconciliation automation) or\
            \ SYSTEM."
          enum:
          - USER
          - POLICY
          - SYSTEM
          x-extensible-enum: true
        approvedByName:
          type: string
          nullable: true
        companyId:
          type: string
          format: uuid
        period:
          type: integer
          format: int32
        periodType:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          x-extensible-enum: true
        policy:
          type: string
          description: The automation policy behind a POLICY approval.
          nullable: true
        revokeNote:
          type: string
          description: The revoking person's own note.
          nullable: true
        revokeReasonCode:
          type: string
          description: "Why it was revoked, e.g. USER_REVOKED, RE_APPROVAL, BALANCE_CHANGED."
          nullable: true
        revokedAt:
          type: string
          format: date-time
          nullable: true
        revokedBy:
          type: string
          format: uuid
          nullable: true
        revokedByName:
          type: string
          nullable: true
        runId:
          type: string
          nullable: true
        source:
          type: string
          description: CAR (automation) or LINKED_BALANCE_RECONCILIATION; null for
            a manual approval.
          enum:
          - CAR
          - LINKED_BALANCE_RECONCILIATION
          nullable: true
          x-extensible-enum: true
        stale:
          type: boolean
          description: A standing approval whose evidence has drifted since.
        staleReasons:
          type: array
          items:
            type: string
        status:
          type: string
          enum:
          - APPROVED
          - REVOKED
          x-extensible-enum: true
        transactionCount:
          type: integer
          format: int64
          nullable: true
        validFrom:
          type: string
          format: date
        validTo:
          type: string
          format: date
          description: Exclusive end of the approved range.
        year:
          type: integer
          format: int32
      required:
      - accountNumber
      - approvalId
      - approvalType
      - approvedAt
      - approvedAutomatically
      - approvedByKind
      - companyId
      - period
      - periodType
      - stale
      - staleReasons
      - status
      - validFrom
      - validTo
      - year
    ApprovalSummary:
      type: object
      description: The standing approval of an account for the period.
      properties:
        approvalId:
          type: string
          format: uuid
        approvalPolicy:
          type: string
          description: "The approval policy the approval was given under: ONE_APPROVER,\
            \ APPROVER_AND_CONTROLLER, or LEGACY (given before policies existed);\
            \ null when the writer records none (automatic approvals), and the company's\
            \ settings decide."
          enum:
          - ONE_APPROVER
          - APPROVER_AND_CONTROLLER
          - LEGACY
          nullable: true
          x-extensible-enum: true
        approvedAt:
          type: string
          format: date-time
          nullable: true
        approvedAutomatically:
          type: boolean
          description: "True when the reconciliation automation approved it, not a\
            \ person."
        approvedBy:
          type: string
          format: uuid
          description: "The approving user; for an automatic approval, the automation's\
            \ own identity or null."
          nullable: true
        approvedByName:
          type: string
          description: The approver's full name; null for an automatic approval or
            when unknown.
          nullable: true
        awaitingControl:
          type: boolean
          description: "Approved, but the approval policy still asks for a control\
            \ by another person: the period is not reconciled until it is given."
        controlledAt:
          type: string
          format: date-time
          description: When the control covering the period was given; null when there
            is none.
          nullable: true
        controlledBy:
          type: string
          format: uuid
          description: The person who gave the control.
          nullable: true
        documentationAsOf:
          type: string
          description: When the newest documentation behind the approval was uploaded
            (ISO-8601).
          nullable: true
        documentationCarriedFromYear:
          type: integer
          format: int32
          description: "The accounting year the documentation was carried forward\
            \ from, when it was."
          nullable: true
        runId:
          type: string
          description: "The automation run behind an automatic approval, when recorded."
          nullable: true
        status:
          type: string
          description: APPROVED.
          enum:
          - APPROVED
          x-extensible-enum: true
      required:
      - approvalId
      - approvedAutomatically
      - awaitingControl
      - status
    AssignRequest:
      type: object
      properties:
        userId:
          type: string
          format: uuid
      required:
      - userId
    AssignmentResponse:
      type: object
      description: A user's assignment to an access policy.
      properties:
        id:
          type: string
          format: uuid
          description: The assignment's stable identifier.
        policyId:
          type: string
          format: uuid
        userId:
          type: string
          format: uuid
      required:
      - id
      - policyId
      - userId
    Association:
      type: object
      description: "An attachment target: the whole company, or one voucher."
      nullable: true
      properties:
        type:
          type: string
          enum:
          - COMPANY
          - VOUCHER
          example: VOUCHER
          x-extensible-enum: true
        value:
          type: string
          description: "The company id, or the voucher's voucherKey."
      required:
      - type
      - value
    AssociationInput:
      type: object
      properties:
        type:
          type: string
          description: "COMPANY: the whole company. VOUCHER: one voucher, by its voucherKey\
            \ (as general-ledger lines and vouchers return it). Any case is accepted."
          enum:
          - COMPANY
          - VOUCHER
          example: VOUCHER
        value:
          type: string
          description: "The voucherKey, required for VOUCHER; ignored for COMPANY."
          maxLength: 200
          nullable: true
      required:
      - type
    AttachedTo:
      type: object
      description: "An attachment target: the whole company, one voucher, an account,\
        \ a reconciliation run or an ERP ledger."
      properties:
        period:
          type: integer
          format: int32
          description: "Account documents only: the period within the year."
          nullable: true
        periodType:
          type: string
          description: "Account documents only: the period's cadence."
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          nullable: true
          x-extensible-enum: true
        type:
          type: string
          description: "COMPANY, VOUCHER, ACCOUNT, RECON_RUN or ERP_LEDGER."
          enum:
          - COMPANY
          - VOUCHER
          - ACCOUNT
          - RECON_RUN
          - ERP_LEDGER
          example: VOUCHER
          x-extensible-enum: true
        value:
          type: string
          description: "The company id, the voucher's voucherKey, the account id (as\
            \ accountId elsewhere), the run id or the ledger id."
        year:
          type: integer
          format: int32
          description: "Account documents only: the year the document belongs to."
          nullable: true
      required:
      - type
      - value
    AuditEventActor:
      type: object
      description: "Who did it: a person, the platform, an integration or Accountflow\
        \ support."
      properties:
        displayName:
          type: string
          description: Name as shown in the app (or the integration's name).
          nullable: true
        role:
          type: string
          nullable: true
        source:
          type: string
          description: "USER, SYSTEM, INTEGRATION or SUPPORT."
          enum:
          - USER
          - SYSTEM
          - INTEGRATION
          - SUPPORT
          x-extensible-enum: true
        userId:
          type: string
          format: uuid
          description: The person's user id; absent for system actors.
          nullable: true
      required:
      - source
    AuditEventResponse:
      type: object
      description: "One event of the organization's audit log: who did what, when,\
        \ to what."
      properties:
        action:
          type: string
          description: Machine action key.
          example: access_policy.assigned
        actionLabel:
          type: string
          description: Human label as recorded.
          nullable: true
        actionLabelI18n:
          type: string
          description: The label's i18n key.
          nullable: true
        actor:
          $ref: "#/components/schemas/AuditEventActor"
        after:
          type: object
          additionalProperties:
            type: object
            description: Registered fields after the change.
            nullable: true
          description: Registered fields after the change.
          nullable: true
        before:
          type: object
          additionalProperties:
            type: object
            description: Registered fields before the change.
            nullable: true
          description: Registered fields before the change.
          nullable: true
        correlationId:
          type: string
          format: uuid
          description: Groups events that belong to one operation.
          nullable: true
        id:
          type: string
          format: uuid
          description: Event id.
        metadata:
          type: object
          additionalProperties:
            type: object
            description: "Free-form context (the company, the account, the period,\
              \ amounts, ...)."
            nullable: true
          description: "Free-form context (the company, the account, the period, amounts,\
            \ ...)."
          nullable: true
        occurredAt:
          type: string
          format: date-time
          description: When it happened.
        source:
          type: string
          description: The service that recorded it.
          enum:
          - CORE
          - BRIDGE
          - INGEST
          - CAR
          example: CORE
          x-extensible-enum: true
        targetId:
          type: string
          format: uuid
          description: The id of the thing it was done to.
        targetLabel:
          type: string
          description: The thing's name as recorded.
          nullable: true
        targetType:
          type: string
          description: "What kind of thing it was done to, as targetType filters it."
          enum:
          - ACCESS_POLICY
          - ACCESS_POLICY_ASSIGNMENT
          - ACCESS_POLICY_RULE
          - ACCOUNT
          - ACCRUAL
          - API_CLIENT
          - ATTACHMENT
          - BANK_ACCOUNT
          - BANK_TRANSACTION
          - CAR_RUN
          - COMPANY
          - DOCUMENT
          - DOCUMENTATION_REQUEST
          - GROUP
          - INTEGRATION_CREDENTIAL
          - INTERCOMPANY_DEFINITION
          - INTERCOMPANY_GROUP
          - OPENING_BALANCE
          - ORGANIZATION
          - PORTFOLIO
          - RECONCILIATION
          - RECONCILIATION_ADJUSTMENT
          - ROUTINE_DESCRIPTION
          - TASK
          - USER
          - WEBHOOK_ENDPOINT
          - WORKFLOW_APPROVAL
          - WORKFLOW_COMMENT
          - WORKFLOW_FLAG
          - WORKFLOW_MATCH
          example: ACCESS_POLICY
          x-extensible-enum: true
      required:
      - action
      - actor
      - id
      - occurredAt
      - source
      - targetId
      - targetType
    Automatch:
      type: object
      description: How the automatcher made a settlement.
      nullable: true
      properties:
        algorithms:
          type: array
          description: "The matching algorithms used (EXACT_1_1, MILP_ZERO_SUM, ...)."
          items:
            type: string
            description: "The matching algorithms used (EXACT_1_1, MILP_ZERO_SUM,\
              \ ...)."
        confidence:
          type: number
          description: "Confidence 0-100: the weakest score among the match details."
          nullable: true
        matchedAt:
          type: string
          format: date-time
          description: When it matched.
          nullable: true
        ruleIds:
          type: array
          description: The account match rules whose pass produced it; empty for the
            general pass.
          items:
            type: string
            description: The account match rules whose pass produced it; empty for
              the general pass.
      required:
      - algorithms
      - ruleIds
    BalanceReconEstimateFlag:
      type: object
      description: "estimate_flags: the non-blocking checks."
      properties:
        accountNumber:
          type: string
          description: "ratio_vs_account: the account to compare against (its account\
            \ number)."
          nullable: true
        maxDriftPct:
          type: number
          format: double
          description: "ratio_vs_account: drift in percent before the flag fires."
          nullable: true
        type:
          type: string
          enum:
          - ratio_vs_account
          - expects_reversal
          x-extensible-enum: true
        withinPeriods:
          type: integer
          format: int32
          description: "expects_reversal: periods a balance may stand before the flag\
            \ fires."
          nullable: true
      required:
      - type
    BalanceReconRule:
      type: object
      description: "How a balance account is proven reconciled: one method and its\
        \ parameters."
      nullable: true
      properties:
        accounts:
          type: array
          description: "account_match: account codes or ranges whose balances are\
            \ summed."
          items:
            type: string
            description: "account_match: account codes or ranges whose balances are\
              \ summed."
          nullable: true
        approvalTargets:
          type: array
          description: "account_match: exact balance-template account codes approved\
            \ together."
          items:
            type: string
            description: "account_match: exact balance-template account codes approved\
              \ together."
          nullable: true
        counterAccounts:
          type: array
          description: "counter_rule: account codes or inclusive ranges, e.g. 8900-8999."
          items:
            type: string
            description: "counter_rule: account codes or inclusive ranges, e.g. 8900-8999."
          nullable: true
        flags:
          type: array
          description: "estimate_flags: the non-blocking checks."
          items:
            $ref: "#/components/schemas/BalanceReconEstimateFlag"
          nullable: true
        groupAccounts:
          type: array
          description: "register_match with scope group: account codes or ranges summed."
          items:
            type: string
            description: "register_match with scope group: account codes or ranges\
              \ summed."
          nullable: true
        method:
          type: string
          enum:
          - carry_forward
          - counter_rule
          - account_match
          - register_match
          - estimate_flags
          - manual
          x-extensible-enum: true
        relation:
          type: string
          description: "account_match: how the two balances relate."
          enum:
          - equal
          - opposite
          nullable: true
          x-extensible-enum: true
        reportCommentTemplate:
          type: string
          description: "account_match: the report note, with {tokens} such as {ownerBalance}."
          maxLength: 2000
          nullable: true
        scope:
          type: string
          description: "register_match: the account alone, or a group of accounts\
            \ summed."
          enum:
          - account
          - group
          nullable: true
          x-extensible-enum: true
        source:
          type: string
          description: "register_match: the register figure to compare against."
          enum:
          - regnskapsregisteret.innskutt_egenkapital
          - enhetsregisteret.aksjekapital
          nullable: true
          x-extensible-enum: true
      required:
      - method
    BankAccount:
      type: object
      description: A bank account connected to the company.
      properties:
        accountType:
          type: string
          nullable: true
        availableBalance:
          type: number
          nullable: true
        balanceUpdatedAt:
          type: string
          format: date-time
          description: When the balances were last synced from the bank.
          nullable: true
        bankAccountNumber:
          type: string
          description: "The bank's own number for the account (kontonummer): not a\
            \ GL account number; glAccountNumber is the GL account it is mapped to."
          nullable: true
        bic:
          type: string
          nullable: true
        bookedBalance:
          type: number
          nullable: true
        currencyCode:
          type: string
          example: NOK
          nullable: true
        glAccountNumber:
          type: string
          description: "The mapped GL account number, when reconciliation is set up."
          nullable: true
        glMappingValidFrom:
          type: string
          format: date
          description: The first day the mapping to glAccountNumber holds; null when
            it has no start (it holds from the account's first line).
          nullable: true
        glMappingValidTo:
          type: string
          format: date
          description: "The last day the mapping to glAccountNumber holds; null while\
            \ it is in force. Set on an account the company moved away from (a bank\
            \ move): the mapping that ended last is shown."
          nullable: true
        glMappings:
          type: array
          description: "Every GL mapping the account has had, oldest first: which\
            \ GL account it fed on which days. glAccountNumber and glMappingValidFrom/glMappingValidTo\
            \ above are the one in force, else the one that ended last. Empty when\
            \ the account was never mapped."
          items:
            $ref: "#/components/schemas/GlMapping"
        iban:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
          description: The account's stable identifier.
        movedOn:
          type: string
          format: date
          description: "After a bank move: the first day this account fed the GL account\
            \ instead of its predecessor."
          nullable: true
        name:
          type: string
          nullable: true
        predecessorId:
          type: string
          format: uuid
          description: "After a bank move: the bank account this one replaced on the\
            \ same GL account. Two accounts on one GL account with no such link share\
            \ it instead."
          nullable: true
        source:
          type: string
          description: "PROVIDER: fed by a bank connection or statement files. MANUAL:\
            \ fed only by uploads a person confirmed (never synced from a bank)."
          enum:
          - PROVIDER
          - MANUAL
          example: PROVIDER
          x-extensible-enum: true
        status:
          type: string
          description: The bank account's state as reported by the bank feed.
          example: active
        syncedThrough:
          type: string
          format: date
          description: "The last day the account's lines have been read through: for\
            \ a PROVIDER account the latest day any of its bank connections synced\
            \ it through, for a MANUAL account the last booking date of its uploads\
            \ still in force. Null when nothing has been read yet. The same day the\
            \ summary's approval figures judge readThrough on."
          nullable: true
      required:
      - glMappings
      - id
      - source
      - status
    BankEntry:
      type: object
      description: One matched bank transaction.
      properties:
        amount:
          type: number
        bankTransactionId:
          type: string
          format: uuid
          description: The bank transaction's id (list_bank_transactions).
      required:
      - amount
      - bankTransactionId
    BankGlAccountSummary:
      type: object
      description: "A BANK GL account's figures for one account period, by the bank\
        \ approval's rules, across every bank account that fed it in the period (after\
        \ a bank move, the old and the new one)."
      properties:
        approvalFigures:
          $ref: "#/components/schemas/ApprovalFigures"
        year:
          type: integer
          format: int32
          description: The accounting year.
      required:
      - approvalFigures
      - year
    BankGlLine:
      type: object
      description: "A general-ledger line of the GL account a bank account feeds,\
        \ with its bank reconciliation state."
      properties:
        accountNumber:
          type: string
          description: The GL account the line is posted to.
          example: "1920"
        amount:
          type: number
          description: "Amount in the base currency (signed; debit positive): a payment\
            \ out is negative, the same sign as the bank transaction."
        baseCurrency:
          type: string
          description: The base currency.
          example: NOK
          nullable: true
        description:
          type: string
          description: "The line's text, else its voucher's: list_general_ledger_lines'\
            \ description."
          nullable: true
        lineId:
          type: string
          description: "The line's stable id: lineId in list_general_ledger_lines,\
            \ and what create_reconciliation's lineIds take."
        period:
          type: integer
          format: int32
          description: "Month of the accounting year, 1-12."
        reconciliationGroupId:
          type: string
          format: uuid
          description: "The reconciliation group holding the line, stale or not (get_reconciliation's\
            \ reconciliationGroupId); null when it is in none."
          nullable: true
        reconciliationStatus:
          type: string
          description: "UNRECONCILED: in no reconciliation group. RECONCILED: in a\
            \ live group against bank transactions. STALE: in a group that needs review\
            \ (matched data changed). CORRECTION / MANUAL_CORRECTION: in a live group\
            \ of ledger posts only (a posting and its reversal), made by the automatcher\
            \ / by a person. Every status but UNRECONCILED and STALE closes the line,\
            \ as the bank approval counts it. Recomputed on every read."
          enum:
          - UNRECONCILED
          - RECONCILED
          - STALE
          - CORRECTION
          - MANUAL_CORRECTION
          example: UNRECONCILED
          x-extensible-enum: true
        transactionAmount:
          type: number
          description: "Amount in the currency the line was booked in: what a foreign-currency\
            \ bank account is matched on."
          nullable: true
        transactionCurrency:
          type: string
          description: The currency the line was booked in.
          example: EUR
          nullable: true
        transactionDate:
          type: string
          format: date
          description: Document/transaction date (bilagsdato).
          nullable: true
        voucherNo:
          type: string
          description: The voucher (bilag) number.
          nullable: true
        year:
          type: integer
          format: int32
          description: The accounting year.
      required:
      - accountNumber
      - amount
      - lineId
      - period
      - reconciliationStatus
      - year
    BankOpeningBalance:
      type: object
      description: "A bank account's opening balance for one accounting year: the\
        \ bank's balance walked back over everything booked since the year began (or\
        \ a person's override), cross-checked against the GL account's own opening\
        \ balance. Recomputed on every read; nothing derived is stored."
      properties:
        balanceUpdatedAt:
          type: string
          format: date-time
          description: When the bank last reported that balance.
          nullable: true
        bankAccountId:
          type: string
          format: uuid
        bookedBalance:
          type: number
          description: The bank's booked balance the walk-back starts from.
          nullable: true
        calculatedOpeningBalance:
          type: number
          description: "bookedBalance less transactionTotal: the balance walked back\
            \ to the year's first day. Null when the bank has reported no balance\
            \ yet."
          nullable: true
        currencyCode:
          type: string
          description: "The bank account's currency, as the bank reports it; the bank\
            \ side's amounts are in it."
          example: NOK
          nullable: true
        difference:
          type: number
          description: openingBalance + otherAccountsOpeningBalance - glOpeningBalance.
            Null when status is UNAVAILABLE.
          nullable: true
        glAccountNumber:
          type: string
          description: "The GL account the ledger side is read from: the one the bank\
            \ account fed on the year's first day, else its mapping in force (or the\
            \ one that ended last). Null when the bank account was never mapped."
          example: "1920"
          nullable: true
        glOpeningBalance:
          type: number
          description: "The ledger's opening balance on that GL account for the year:\
            \ the sum of the ERP's opening-balance rows on the year's ledger, in the\
            \ bank's currency when every row states one in it, else in the base currency.\
            \ Null when the ERP delivered none, which is not the same as zero."
          nullable: true
        glOpeningBalanceCurrency:
          type: string
          description: "The currency glOpeningBalance is in: the bank's currency when\
            \ the ledger states the opening in it, else the ledger's base currency.\
            \ Null when glOpeningBalance is, or when the ERP stated no currency. Differs\
            \ from currencyCode when status is UNAVAILABLE with CURRENCY_MISMATCH:\
            \ the two figures are then in different units."
          example: NOK
          nullable: true
        openingBalance:
          type: number
          description: "The opening balance in force: the override when one is set,\
            \ else calculatedOpeningBalance."
          nullable: true
        otherAccountsOpeningBalance:
          type: number
          description: "The opening balance in force on the other bank accounts that\
            \ fed the same GL account on the year's first day: the ledger figure covers\
            \ them all, so the difference is taken against their sum. Null when no\
            \ other account did."
          nullable: true
        override:
          $ref: "#/components/schemas/OpeningBalanceOverride"
        source:
          type: string
          description: "Where openingBalance comes from: CALCULATED (walked back from\
            \ the bank's balance) or MANUAL (a person's override)."
          enum:
          - CALCULATED
          - MANUAL
          example: CALCULATED
          x-extensible-enum: true
        status:
          type: string
          description: "MATCHED: the difference is within tolerance. DEVIATION: it\
            \ is not. UNAVAILABLE: there is nothing to compare (unavailableReasonCode\
            \ says why)."
          enum:
          - MATCHED
          - DEVIATION
          - UNAVAILABLE
          example: MATCHED
          x-extensible-enum: true
        tolerance:
          type: number
          description: "How far apart the two sides may be and still count as MATCHED,\
            \ in the account's currency."
        transactionCount:
          type: integer
          format: int32
          description: How many lines transactionTotal covers.
        transactionTotal:
          type: number
          description: "The booked movement since the year's first day, walked back\
            \ over: booked lines a bank or a file delivered, dated (booking date,\
            \ else value date) on or after it. Lines a person typed in are left out:\
            \ the bank's balance already holds them."
        unavailableReason:
          type: string
          description: "Why the comparison could not be made, in English, when status\
            \ is UNAVAILABLE."
          nullable: true
        unavailableReasonCode:
          type: string
          description: "The code behind unavailableReason: UNMAPPED (no GL mapping),\
            \ NO_BANK_BALANCE (no balance from the bank yet, on this account or another\
            \ feeding the GL account), NO_GL_OPENING_BALANCE (the ledger holds none\
            \ for the year), CURRENCY_MISMATCH (the figures are in different currencies),\
            \ MANUAL_ACCOUNT (a manual account's lines are uploaded by people, so\
            \ no bank figure exists, on this account or another feeding the GL account),\
            \ MOVED_IN_DURING_YEAR (a bank move: the account took over the GL account\
            \ after the year's first day) or NOT_MAPPED_THIS_YEAR (a bank move: it\
            \ fed the GL account only before or after the year)."
          enum:
          - UNMAPPED
          - NO_BANK_BALANCE
          - NO_GL_OPENING_BALANCE
          - CURRENCY_MISMATCH
          - MANUAL_ACCOUNT
          - MOVED_IN_DURING_YEAR
          - NOT_MAPPED_THIS_YEAR
          nullable: true
          x-extensible-enum: true
        year:
          type: integer
          format: int32
          description: The accounting year.
      required:
      - bankAccountId
      - source
      - status
      - tolerance
      - transactionCount
      - transactionTotal
      - year
    BankTransaction:
      type: object
      description: A bank transaction with its computed reconciliation state.
      properties:
        amount:
          type: number
          description: "Signed amount: money out of the account is negative, money\
            \ in positive. The GL line that books the same movement has the same sign."
        bookingDate:
          type: string
          format: date
          nullable: true
        counterpartyAccount:
          type: string
          nullable: true
        counterpartyName:
          type: string
          nullable: true
        currencyCode:
          type: string
          example: NOK
          nullable: true
        description:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
          description: The transaction's stable identifier.
        reconciliationGroupId:
          type: string
          format: uuid
          description: "The reconciliation group holding the transaction, when matched:\
            \ the group's id (get_reconciliation's reconciliationGroupId)."
          nullable: true
        reconciliationStatus:
          type: string
          description: "Computed on every read: UNRECONCILED | RECONCILED | STALE.\
            \ STALE means the matched data changed after matching — re-reconcile."
          enum:
          - UNRECONCILED
          - RECONCILED
          - STALE
          example: RECONCILED
          x-extensible-enum: true
        remittanceInfo:
          type: string
          nullable: true
        source:
          type: string
          description: "Where the line came from: PROVIDER_API (a bank connection),\
            \ FILE_UPLOAD (a statement file from the bank), MANUAL_IMPORT (a statement\
            \ a person uploaded to a manual account) or MANUAL_ENTRY (a line a person\
            \ typed in). A MANUAL_ENTRY line is in no bank balance: the bank's own\
            \ balance already holds it."
          enum:
          - PROVIDER_API
          - FILE_UPLOAD
          - MANUAL_IMPORT
          - MANUAL_ENTRY
          x-extensible-enum: true
        status:
          type: string
          enum:
          - BOOKED
          - PENDING
          example: BOOKED
          x-extensible-enum: true
        valueDate:
          type: string
          format: date
          nullable: true
        withdrawnAt:
          type: string
          format: date-time
          description: When the bank withdrew this booked line (it reported it no
            longer exists). The line is kept until a person removes it; it is in no
            bank balance the bank reports. Null for a line the bank stands by.
          nullable: true
      required:
      - amount
      - id
      - reconciliationStatus
      - source
      - status
    BlockerResponse:
      type: object
      description: A reason automation cannot make progress for a company.
      properties:
        accountId:
          type: string
          format: uuid
          description: "AUTOMATION_FAILED on an account: the account's id, when it\
            \ resolved."
          nullable: true
        accountName:
          type: string
          nullable: true
        accountNumber:
          type: string
          nullable: true
        affectedCount:
          type: integer
          format: int32
          description: "UNMAPPED_ACCOUNTS: how many accounts are unmapped."
          nullable: true
        companyId:
          type: string
          format: uuid
        companyName:
          type: string
        credentialEndDate:
          type: string
          format: date
          description: "ERP_CREDENTIALS: the day the credential expired; null when\
            \ none is set up."
          nullable: true
        erpSystem:
          type: string
          description: "ERP_CREDENTIALS: the connected ERP system, when there is one."
          nullable: true
        id:
          type: string
          description: Stable key of the blocker across calls.
        importType:
          type: string
          description: "AUTOMATION_FAILED on a fetch: what was being fetched (dataset\
            \ import type)."
          nullable: true
        kind:
          type: string
          description: "ERP_CREDENTIALS (no working ERP connection), AUTOMATION_FAILED\
            \ (a reconciliation task or an ERP fetch of the latest automation run\
            \ failed), UNMAPPED_ACCOUNTS (accounts with no standard account mapped)."
          enum:
          - ERP_CREDENTIALS
          - AUTOMATION_FAILED
          - UNMAPPED_ACCOUNTS
          x-extensible-enum: true
        message:
          type: string
          description: "AUTOMATION_FAILED: the worker's own error message, verbatim."
          nullable: true
        severity:
          type: string
          description: "CRITICAL when automation is stopped, HIGH when it runs but\
            \ leaves data out."
          enum:
          - CRITICAL
          - HIGH
          x-extensible-enum: true
      required:
      - companyId
      - companyName
      - id
      - kind
      - severity
    BulkAccountMapping:
      type: object
      properties:
        companyId:
          type: string
          format: uuid
        failed:
          type: integer
          format: int32
        mapped:
          type: integer
          format: int32
        rows:
          type: array
          items:
            $ref: "#/components/schemas/AccountMappingResult"
        submitted:
          type: integer
          format: int32
      required:
      - companyId
      - failed
      - mapped
      - rows
      - submitted
    ChooseAccountTemplateRequest:
      type: object
      properties:
        accountTemplateId:
          type: string
          format: uuid
          description: A template of the company's organization. Absent (or null)
            leaves the choice as it is.
          nullable: true
        expectedVersion:
          type: string
          description: The version the read returned; refused with 409 if the choice
            changed since.
          maxLength: 64
          nullable: true
        reset:
          type: array
          description: "[\"accountTemplateId\"] drops the company's own choice: it\
            \ follows the organization's default again."
          items:
            type: string
            enum:
            - accountTemplateId
          maxItems: 1
          nullable: true
    ClearAutomationOverridesRequest:
      type: object
      properties:
        settingsRevision:
          type: integer
          format: int64
          description: The settingsRevision a read returned.
      required:
      - settingsRevision
    CloseStatusResponse:
      type: object
      description: Month-close status for one company and period.
      properties:
        closePercent:
          type: integer
          format: int32
          description: "Share (0-100) of reconcilable balance accounts that are reconciled;\
            \ 100 only when all are, 0 only when none are."
        companyId:
          type: string
          format: uuid
        companyName:
          type: string
        period:
          type: integer
          format: int32
        periodType:
          type: string
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          x-extensible-enum: true
        stages:
          type: array
          items:
            $ref: "#/components/schemas/Stage"
        year:
          type: integer
          format: int32
      required:
      - closePercent
      - companyId
      - companyName
      - period
      - periodType
      - stages
      - year
    CommentResponse:
      type: object
      description: "A comment on a reconciliation subject: an account's period balance,\
        \ a GL line, an opening balance, a sub-ledger open item, or a bank line."
      properties:
        accountNumber:
          type: string
          description: "The account number, for account-addressed comments."
          nullable: true
        authorKind:
          type: string
          description: USER | SYSTEM.
          enum:
          - USER
          - SYSTEM
          example: USER
          x-extensible-enum: true
        comment:
          type: string
          description: The comment text.
        commentType:
          type: string
          description: GL_BALANCE_RECON | GL_LINE_RECON | OPENING_BALANCE_RECON |
            SUB_LEDGER_OPEN_ITEM_RECON | BANK_TRANSACTION_RECON (other types written
            in the app are listed as stored).
          enum:
          - GL_BALANCE_RECON
          - GL_LINE_RECON
          - OPENING_BALANCE_RECON
          - SUB_LEDGER_OPEN_ITEM_RECON
          - BANK_TRANSACTION_RECON
          example: GL_BALANCE_RECON
          x-extensible-enum: true
        createdAt:
          type: string
          format: date-time
          description: When the comment was written.
        createdBy:
          type: string
          format: uuid
          description: The author.
          nullable: true
        createdByName:
          type: string
          description: The author's name; null when none is on record. Never an e-mail
            address.
          nullable: true
        id:
          type: string
          format: uuid
          description: Comment id.
        mentions:
          type: array
          description: "The users @-mentioned in the text, in text order (empty when\
            \ none)."
          items:
            $ref: "#/components/schemas/Mention"
        period:
          type: integer
          format: int32
          description: "Period within the year, 1 to the cadence's period count."
          nullable: true
        periodType:
          type: string
          description: MONTHLY | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY |
            YEARLY.
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          nullable: true
          x-extensible-enum: true
        source:
          type: string
          description: Machine source of a SYSTEM comment.
          nullable: true
        subjectKey:
          $ref: "#/components/schemas/SubjectKey"
        year:
          type: integer
          format: int32
          description: Fiscal year of the period scope (account-balance comments only).
          nullable: true
      required:
      - authorKind
      - comment
      - commentType
      - createdAt
      - id
      - mentions
      - subjectKey
    CompanyAccessResponse:
      type: object
      description: "One person who reaches the company: the effective role per resource\
        \ and every grant behind it."
      properties:
        accountGrants:
          type: array
          description: Roles on single account codes that exceed unrestrictedRole.
          items:
            $ref: "#/components/schemas/EffectiveAccessAccountGrant"
        displayName:
          type: string
          description: First and last name; null when neither is on record.
          nullable: true
        role:
          type: string
          description: The highest role the person holds anywhere in the company.
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: ACCOUNTANT
          x-extensible-enum: true
        sources:
          type: array
          description: "Every grant that reaches the company: each policy rule (with\
            \ a time-bound grant's window), or the organization-admin reach. Exactly\
            \ one is decisive."
          items:
            $ref: "#/components/schemas/EffectiveAccessSource"
        status:
          type: string
          description: "Lifecycle state. A DISABLED or DELETED person reaches nothing,\
            \ so is not listed; null when Accountflow holds no profile for the id."
          enum:
          - ACTIVE
          - DISABLED
          - DELETED
          nullable: true
          x-extensible-enum: true
        templateGrants:
          type: array
          description: Roles on a template's accounts that exceed unrestrictedRole.
          items:
            $ref: "#/components/schemas/EffectiveAccessTemplateGrant"
        unrestrictedRole:
          type: string
          description: The role on every account of the company. Null when every grant
            is restricted to templates or account codes.
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          nullable: true
          x-extensible-enum: true
        userId:
          type: string
          format: uuid
          description: "The user's id, as list_org_users and get_effective_access\
            \ take it."
      required:
      - accountGrants
      - role
      - sources
      - templateGrants
      - userId
    CompanyAccountTemplate:
      type: object
      properties:
        accountTemplateId:
          type: string
          format: uuid
          description: The template in use; absent when the organization has no default.
          nullable: true
        available:
          type: array
          description: "The organization's templates, the default first."
          items:
            $ref: "#/components/schemas/AccountTemplateRef"
        chosen:
          type: boolean
          description: "Whether the company chose it, rather than following the organization's\
            \ default."
        companyId:
          type: string
          format: uuid
        managedSince:
          type: string
          format: date-time
          description: Since when the company's accounts follow the template.
          nullable: true
        name:
          type: string
          nullable: true
        version:
          type: string
          description: Pass back as expectedVersion to choose.
      required:
      - available
      - chosen
      - companyId
      - version
    CompanyAutomationChange:
      type: object
      description: Automatic reconciliation to change; absent fields stay unchanged.
      nullable: true
      properties:
        amountToleranceNok:
          type: number
          description: "Largest residual the automatic approval tolerates, compared\
            \ with the ledger's amounts as they are."
          example: 0.05
          maximum: 100
          minimum: 0
          nullable: true
        autoApprove:
          type: boolean
          description: Let a finished run mark a fully reconciled account and period
            approved without a person. Only while autoReconcile is on.
          nullable: true
        autoPostOnHighConfidence:
          type: boolean
          description: Post confident matches without review.
          nullable: true
        autoReconcile:
          type: boolean
          description: "Whether automatic reconciliation runs for the company at all.\
            \ Automatic approval can only be on while it is: turning it off needs\
            \ autoApprove off as well."
          nullable: true
        dayTolerance:
          type: integer
          format: int32
          description: Days a match may be apart.
          maximum: 365
          minimum: 0
          nullable: true
        frequency:
          type: string
          description: How often it runs; a new cadence applies from the run after
            the next.
          enum:
          - DAILY
          - EVERY_OTHER_DAY
          - WEEKLY
          - MONTHLY
          nullable: true
        maxGroupSize:
          type: integer
          format: int32
          description: Most lines one match may group.
          maximum: 100
          minimum: 0
          nullable: true
        minConfidenceScore:
          type: integer
          format: int32
          description: Lowest confidence a match needs.
          maximum: 100
          minimum: 0
          nullable: true
        modules:
          type: array
          description: "Per-module overrides of these defaults, one entry per module.\
            \ A module's value applies only while the company's automatic reconciliation\
            \ is on, except VAT's and PAYROLL's, which run unless switched off."
          items:
            $ref: "#/components/schemas/CompanyAutomationModuleChange"
          maxItems: 11
          nullable: true
        requireExactCounterparty:
          type: boolean
          nullable: true
        secondPassEnabled:
          type: boolean
          description: "Run a second, wider pass over lines the first pass left open."
          nullable: true
        secondPassMaxOpenLines:
          type: integer
          format: int32
          description: Most open lines the second pass takes on; 0 means it never
            runs.
          maximum: 10000
          minimum: 0
          nullable: true
        secondPassWindowDays:
          type: integer
          format: int32
          maximum: 365
          minimum: 0
          nullable: true
        suggestionsEnabled:
          type: boolean
          description: Let the matcher leave suggestions for review.
          nullable: true
    CompanyAutomationModuleChange:
      type: object
      description: Override the company's automation defaults for one module.
      properties:
        autoApprove:
          type: boolean
          description: "Let finished runs approve this module's reconciled accounts\
            \ without a person; never while the module's own automatic reconciliation\
            \ is off. Not for CURRENCY_K28 or CURRENCY_K29, which never approve: only\
            \ false is accepted back."
          nullable: true
        bankGlCorrectionsEnabled:
          type: boolean
          description: "BANK only: a last round that pairs a ledger posting with its\
            \ reversal (same date, same amount, opposite sign) that no bank line took,\
            \ saved as a correction. Inherited, it is on."
          nullable: true
        bankSecondPassEnabled:
          type: boolean
          description: "BANK only: a last round with a wide window that makes exact-amount\
            \ pairs and groups (a pair needs a single candidate on each side, a group\
            \ no interchangeable same-amount line). Inherited, it is off."
          nullable: true
        bankSecondPassWindowDays:
          type: integer
          format: int32
          description: "BANK only: the days apart the bank second pass's pairs and\
            \ groups may span. Inherited, it is 30."
          maximum: 365
          minimum: 0
          nullable: true
        enabled:
          type: boolean
          description: "Run automatic reconciliation for this module. Never while\
            \ the company's is off, except VAT and PAYROLL, which run unless switched\
            \ off here. CURRENCY_K28 and CURRENCY_K29 run only when switched on here\
            \ (and the company's runs)."
          nullable: true
        flagAbsoluteNok:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, NOK, 0 to 1000000000,\
            \ at most 2 decimals: a deviation above it is flagged whatever the percentage.\
            \ Inherited, it is 1000."
          maximum: 1000000000
          minimum: 0
          nullable: true
        flagFloorNok:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, NOK, 0 to 1000000000,\
            \ at most 2 decimals: the deviation a flag needs beside flagPercent. Inherited,\
            \ it is 10."
          maximum: 1000000000
          minimum: 0
          nullable: true
        flagPercent:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, 0 to 100, at most 2 decimals:\
            \ the deviation in percent of the expected amount above which, together\
            \ with flagFloorNok, a finding is flagged. Inherited, it is 1."
          maximum: 100
          minimum: 0
          nullable: true
        groupWindowDays:
          type: integer
          format: int32
          description: "BANK only: the days the lines of a group (one ledger line\
            \ against several bank lines, or the reverse) may be apart. Inherited,\
            \ it is the module's match window."
          maximum: 365
          minimum: 0
          nullable: true
        highFloorNok:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, NOK, 0 to 1000000000,\
            \ at most 2 decimals, not below the effective flagFloorNok: the deviation\
            \ a high flag needs. Inherited, it is 100."
          maximum: 1000000000
          minimum: 0
          nullable: true
        highPercent:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, 0 to 100, at most 2 decimals,\
            \ not below the effective flagPercent: the percentage of a high flag.\
            \ Inherited, it is 5."
          maximum: 100
          minimum: 0
          nullable: true
        matchWindowDays:
          type: integer
          format: int32
          description: "This module's first-pass window in days; for BANK the days\
            \ a bank line and a ledger line of the same amount may be apart. Not for\
            \ SIMPLE_BANK, BALANCE, ASSETS, VAT, PAYROLL, CURRENCY_K28 or CURRENCY_K29,\
            \ which match no lines."
          maximum: 365
          minimum: 0
          nullable: true
        module:
          type: string
          enum:
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - GENERAL_LEDGER
          - BALANCE
          - ACCRUALS
          - ASSETS
          - VAT
          - PAYROLL
          - CURRENCY_K28
          - CURRENCY_K29
        reset:
          type: array
          description: Fields to return to the inherited value.
          items:
            type: string
            enum:
            - enabled
            - matchWindowDays
            - secondPassEnabled
            - autoApprove
            - groupWindowDays
            - bankSecondPassEnabled
            - bankSecondPassWindowDays
            - bankGlCorrectionsEnabled
            - flagPercent
            - flagFloorNok
            - flagAbsoluteNok
            - highPercent
            - highFloorNok
          maxItems: 13
        secondPassEnabled:
          type: boolean
          description: "The general second pass. Not for BANK (see bankSecondPassEnabled)\
            \ nor SIMPLE_BANK, BALANCE, ASSETS, VAT, PAYROLL, CURRENCY_K28 or CURRENCY_K29,\
            \ which have none; for those only the value get_company_settings shows\
            \ is accepted back, and reset clears an old value."
          nullable: true
      required:
      - module
    CompanyAutomationSettings:
      type: object
      properties:
        amountToleranceNok:
          type: number
          description: Largest residual (NOK) the automatic approval tolerates.
          example: 0.05
        autoApprove:
          type: boolean
          description: Whether a finished run may mark a fully reconciled account
            and period as approved without a person.
        autoPostOnHighConfidence:
          type: boolean
          description: Whether confident matches are posted without review.
        autoReconcile:
          type: boolean
          description: Whether automatic reconciliation runs for the company at all.
        dayTolerance:
          type: integer
          format: int32
          description: Days a match may be apart; null is the reconciliation worker's
            default.
          nullable: true
        frequency:
          type: string
          description: How often it runs.
          enum:
          - DAILY
          - EVERY_OTHER_DAY
          - WEEKLY
          - BIWEEKLY
          - MONTHLY
          - QUARTERLY
          x-extensible-enum: true
        matchWindowDays:
          type: integer
          format: int32
          description: "The first pass's window in days, which a module without its\
            \ own inherits."
        maxGroupSize:
          type: integer
          format: int32
          description: Most lines one match may group; null is the worker's default.
          nullable: true
        minConfidenceScore:
          type: integer
          format: int32
          description: Lowest confidence (0–100) a match needs; null is the worker's
            default.
          nullable: true
        modules:
          type: array
          description: "Every module, in the application's order."
          items:
            $ref: "#/components/schemas/ModuleAutomationSettings"
        requireExactCounterparty:
          type: boolean
        secondPassEnabled:
          type: boolean
          description: "Whether a second, wider pass runs over lines the first pass\
            \ left open."
        secondPassMaxOpenLines:
          type: integer
          format: int32
          description: Most open lines the second pass takes on.
        secondPassWindowDays:
          type: integer
          format: int32
          description: "Half-width of the second pass's window, in days."
        suggestionsEnabled:
          type: boolean
          description: Whether the matcher may leave suggestions for review.
      required:
      - amountToleranceNok
      - autoApprove
      - autoPostOnHighConfidence
      - autoReconcile
      - frequency
      - matchWindowDays
      - modules
      - requireExactCounterparty
      - secondPassEnabled
      - secondPassMaxOpenLines
      - secondPassWindowDays
      - suggestionsEnabled
    CompanyBaseCurrencyYear:
      type: object
      properties:
        accountingYear:
          type: integer
          format: int32
        currencyCode:
          type: string
          description: ISO 4217.
          example: NOK
        inheritedFromYear:
          type: integer
          format: int32
          description: Original decision's year for a frozen inherited value; null
            for a direct decision for accountingYear. Inherited ERP values do not
            lock the year.
          maximum: 2999
          minimum: 1900
          nullable: true
        setAt:
          type: string
          format: date-time
          description: When it was recorded.
        setBy:
          $ref: "#/components/schemas/PersonRef"
        setByApiClientId:
          type: string
          format: uuid
          description: "The API client that set a company setting or created a COUNTRY\
            \ choice; null for ERP and for a choice recorded outside Bridge (the application,\
            \ the launch conversion)."
          nullable: true
        source:
          type: string
          description: "Reported by the company's ERP (ERP), a company setting (COMPANY_SETTING)\
            \ or the company's country (COUNTRY). Only direct ERP evidence for accountingYear\
            \ locks it; inherited ERP values remain editable."
          enum:
          - ERP
          - COMPANY_SETTING
          - COUNTRY
          x-extensible-enum: true
      required:
      - accountingYear
      - currencyCode
      - setAt
      - source
    CompanyContact:
      type: object
      description: A person at the client company documentation requests go to.
      properties:
        active:
          type: boolean
          description: A deactivated contact receives no new requests; requests sent
            to them keep their name.
        companyId:
          type: string
          format: uuid
        defaultRecipient:
          type: boolean
          description: Documentation requests go to this person unless another is
            chosen; one per company.
        email:
          type: string
        fullName:
          type: string
        id:
          type: string
          format: uuid
        phone:
          type: string
          nullable: true
        roles:
          type: array
          description: What the person does for the company.
          enum:
          - DAILY_MANAGER
          - CHAIR
          - FINANCE
          - BOOKKEEPING
          - PAYROLL
          - AUDITOR_CONTACT
          - OTHER
          items:
            type: string
            description: What the person does for the company.
            enum:
            - DAILY_MANAGER
            - CHAIR
            - FINANCE
            - BOOKKEEPING
            - PAYROLL
            - AUDITOR_CONTACT
            - OTHER
            x-extensible-enum: true
          x-extensible-enum: true
      required:
      - active
      - companyId
      - defaultRecipient
      - email
      - fullName
      - id
      - roles
    CompanyContacts:
      type: object
      properties:
        companyId:
          type: string
          format: uuid
        data:
          type: array
          items:
            $ref: "#/components/schemas/CompanyContact"
        pagination:
          $ref: "#/components/schemas/Pagination"
        version:
          type: string
          description: Pass back as expectedVersion to change the contacts.
      required:
      - companyId
      - data
      - pagination
      - version
    CompanyModules:
      type: object
      description: "Which modules the company uses, from its settings. A switch that\
        \ was never set counts as VAT and payroll enabled, fixed assets disabled."
      properties:
        assets:
          type: boolean
          description: Fixed assets (anleggsmidler) are enabled.
          example: false
        payroll:
          type: boolean
          description: Payroll (lønn / A-melding) is enabled.
          example: false
        vat:
          type: boolean
          description: VAT reporting (MVA) is enabled.
          example: true
      required:
      - assets
      - payroll
      - vat
    CompanyResponse:
      type: object
      description: An accounting client (company) within your reach.
      properties:
        companyType:
          type: string
          description: Legal form.
          example: AS
          nullable: true
        countryCode:
          type: string
          description: ISO country code.
          example: "NO"
          nullable: true
        createdAt:
          type: string
          format: date-time
          description: When the company was registered in Accountflow.
        currentAccountingYear:
          type: integer
          format: int32
          description: The accounting year currently being worked.
          nullable: true
        fiscalYearEnd:
          type: string
          format: date
          description: End of the current fiscal year.
        fiscalYearStart:
          type: string
          format: date
          description: Start of the current fiscal year.
        fiscalYearStartMonth:
          type: integer
          format: int32
          description: "Month (1-12) the company's fiscal years start in: the pattern\
            \ a new fiscal year takes. Every fiscal year is twelve months from the\
            \ first of that month; a year that already exists keeps its own dates\
            \ (fiscalYearStart and fiscalYearEnd for the current one)."
          example: 1
          maximum: 12
          minimum: 1
        id:
          type: string
          format: uuid
          description: The company's stable identifier.
        modules:
          $ref: "#/components/schemas/CompanyModules"
        name:
          type: string
          description: Display name.
          example: Fjellheim Regnskap AS
        organizationId:
          type: string
          format: uuid
          description: The organization (accounting firm) this company belongs to.
        organizationNumber:
          type: string
          description: Norwegian organization number.
          example: "987654325"
          nullable: true
        periodType:
          type: string
          description: Accounting period granularity.
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          example: MONTHLY
          nullable: true
          x-extensible-enum: true
        status:
          type: string
          description: "Lifecycle state: ACTIVE or DISABLED. Deleted companies are\
            \ not represented — they 404 until restored."
          enum:
          - ACTIVE
          - DISABLED
          example: ACTIVE
          x-extensible-enum: true
      required:
      - createdAt
      - fiscalYearEnd
      - fiscalYearStart
      - fiscalYearStartMonth
      - id
      - modules
      - name
      - organizationId
      - status
    CompanyResponsiblePeople:
      type: object
      properties:
        auditor:
          $ref: "#/components/schemas/PersonRef"
        controller:
          $ref: "#/components/schemas/PersonRef"
        mainAccountant:
          $ref: "#/components/schemas/PersonRef"
        owner:
          $ref: "#/components/schemas/PersonRef"
    CompanySettings:
      type: object
      description: A company's settings.
      properties:
        automation:
          $ref: "#/components/schemas/CompanyAutomationSettings"
        balanceChangeBasis:
          type: string
          description: Whether account balances are judged by their closing balance
            or the period's movement; read-only here.
          enum:
          - CLOSING_BALANCE
          - PERIOD_MOVEMENT
          nullable: true
          x-extensible-enum: true
        baseCurrencyYears:
          type: array
          description: "The base currency recorded for each accounting year, oldest\
            \ first. A year without an entry takes the latest earlier one, else the\
            \ earliest later one."
          items:
            $ref: "#/components/schemas/CompanyBaseCurrencyYear"
        companyId:
          type: string
          format: uuid
        currencyCode:
          type: string
          description: "The base currency (ISO 4217) of the company's current accounting\
            \ year; null when none is known. A company can change its base currency\
            \ from one accounting year to the next: baseCurrencyYears lists each year.\
            \ Changing it recalculates nothing."
          example: NOK
          nullable: true
        currencySource:
          type: string
          description: "Where the current accounting year's base currency comes from:\
            \ reported by the company's ERP (ERP), a company setting (COMPANY_SETTING)\
            \ or the company's country (COUNTRY). Null with currencyCode."
          enum:
          - ERP
          - COMPANY_SETTING
          - COUNTRY
          nullable: true
          x-extensible-enum: true
        modules:
          $ref: "#/components/schemas/CompanySettingsModules"
        responsible:
          $ref: "#/components/schemas/CompanyResponsiblePeople"
        version:
          type: string
          description: Identifies these values; pass it as expectedVersion to update
            them safely.
      required:
      - automation
      - baseCurrencyYears
      - companyId
      - modules
      - responsible
      - version
    CompanySettingsModules:
      type: object
      properties:
        assets:
          type: boolean
          description: Whether the company keeps a fixed-asset register.
        intercompany:
          type: boolean
          description: Whether the company has intercompany balances.
        payroll:
          type: boolean
          description: Whether the company runs payroll.
        vat:
          type: boolean
          description: Whether the company reports VAT.
      required:
      - assets
      - intercompany
      - payroll
      - vat
    CompanyUserResponse:
      type: object
      description: "A person who can be named as the company's owner, controller,\
        \ main accountant or auditor."
      properties:
        displayName:
          type: string
          description: First and last name; null when neither is on record.
          nullable: true
        email:
          type: string
          description: "The user's e-mail address. Registered API clients only: an\
            \ MCP session never receives it."
          nullable: true
        id:
          type: string
          format: uuid
          description: "The user's id: what ownerUserId, controllerUserId, mainAccountantUserId\
            \ and auditorUserId take."
        role:
          type: string
          description: "The person's role in the company's organization: ADMIN, MEMBER\
            \ or EXTERNAL."
          enum:
          - ADMIN
          - MEMBER
          - EXTERNAL
          example: MEMBER
          nullable: true
          x-extensible-enum: true
        status:
          type: string
          description: Lifecycle state.
          enum:
          - ACTIVE
          - DISABLED
          example: ACTIVE
          x-extensible-enum: true
      required:
      - id
      - status
    Coverage:
      type: object
      description: How the period is covered by standing approvals.
      properties:
        state:
          type: string
          enum:
          - NONE
          - PARTIAL
          - FULL
          x-extensible-enum: true
        validFrom:
          type: string
          format: date
        validTo:
          type: string
          format: date
      required:
      - state
      - validFrom
      - validTo
    CreateApiLedgerRequest:
      type: object
      description: The accounting year to create the company's Api ledger for.
      properties:
        setCurrent:
          type: boolean
          description: "Make the new ledger the company's current one, whatever its\
            \ year. Default false: the current ledger stays current unless the company\
            \ has none or it holds no general-ledger lines."
          example: true
          nullable: true
        year:
          type: integer
          format: int32
          description: The accounting year the ledger holds.
          example: 2026
      required:
      - year
    CreateCompanyContactRequest:
      type: object
      properties:
        defaultRecipient:
          type: boolean
          nullable: true
        email:
          type: string
          maxLength: 254
        expectedVersion:
          type: string
          description: The version the contacts read returned; refused with 409 if
            they changed since.
          maxLength: 64
          nullable: true
        fullName:
          type: string
          maxLength: 200
        phone:
          type: string
          maxLength: 50
          nullable: true
        roles:
          type: array
          items:
            type: string
          nullable: true
      required:
      - email
      - fullName
    CreateCompanyRequest:
      type: object
      properties:
        assetsEnabled:
          type: boolean
          nullable: true
        companyNumber:
          type: string
          maxLength: 32
        companyType:
          type: string
          maxLength: 32
          nullable: true
        countryCode:
          type: string
          description: ISO 3166-1 alpha-2; defaults to NO.
          maxLength: 2
          nullable: true
          pattern: "^[A-Za-z]{2}$"
        currencyCode:
          type: string
          description: "Base currency, ISO 4217, recorded as a company setting for\
            \ the company's current accounting year. Without it the country gives\
            \ one (NO: NOK, SE: SEK, FI: EUR); a country without a single currency\
            \ requires an explicit code, otherwise 400 asking for currencyCode. Both\
            \ sources record the API client and any delegated person."
          example: NOK
          maxLength: 3
          nullable: true
          pattern: "^[A-Za-z]{3}$"
        fiscalYearEnd:
          type: string
          format: date
          deprecated: true
          description: "Deprecated: use fiscalYearStartMonth. Accepted when it ends\
            \ the twelve months from fiscalYearStart (or, alone, is the last day of\
            \ a month); otherwise 422."
          nullable: true
        fiscalYearStart:
          type: string
          format: date
          deprecated: true
          description: "Deprecated: use fiscalYearStartMonth. Accepted when it is\
            \ the first day of a month, which gives the start month (its year is not\
            \ used); otherwise 422."
          nullable: true
        fiscalYearStartMonth:
          type: integer
          format: int32
          description: "Month (1-12) the company's fiscal years start in; defaults\
            \ to 1 (January). Every fiscal year is twelve months from the first of\
            \ this month. The company's first ledger is for the fiscal year that contains\
            \ today: with a July start, a company created in March 2027 starts in\
            \ the 2026 year (July 2026 to June 2027)."
          example: 1
          maximum: 12
          minimum: 1
          nullable: true
        mainAccountantUserId:
          type: string
          format: uuid
          nullable: true
        name:
          type: string
          maxLength: 255
        obMonth:
          type: integer
          format: int32
          deprecated: true
          description: "Deprecated: use fiscalYearStartMonth. Accepted only when it\
            \ equals the start month; otherwise 422."
          maximum: 12
          minimum: 1
          nullable: true
        ownerUserId:
          type: string
          format: uuid
        payrollEnabled:
          type: boolean
          nullable: true
        periodType:
          type: string
          nullable: true
        vatEnabled:
          type: boolean
          description: "Whether VAT is enabled; defaults to false, as in the application."
          nullable: true
      required:
      - companyNumber
      - name
      - ownerUserId
    CreateIntercompanyDefinitionRequest:
      type: object
      properties:
        allowPartialSettlement:
          type: boolean
          nullable: true
        companyGroupId:
          type: string
          format: uuid
        counterpartyMemberId:
          type: string
          format: uuid
        expectedVersion:
          type: string
          description: The version the read returned (the groups' for a new link);
            refused with 409 if it changed since.
          maxLength: 64
          nullable: true
        signConvention:
          type: string
          enum:
          - SUM_ZERO
          - SAME_SIGN
          nullable: true
      required:
      - companyGroupId
      - counterpartyMemberId
    CreatePolicyRequest:
      type: object
      properties:
        description:
          type: string
          maxLength: 2000
          nullable: true
        isDefault:
          type: boolean
          deprecated: true
          description: "Legacy flag: the organization default policy is retired and\
            \ grants nothing. true is refused (400, reason default_policy_retired),\
            \ except on an update of a policy that already carries it (an echo of\
            \ what was read); false clears a stored flag."
          nullable: true
        name:
          type: string
          maxLength: 200
        rules:
          type: array
          items:
            $ref: "#/components/schemas/RuleInput"
          maxItems: 500
          nullable: true
      required:
      - name
    CreateReconciliationRequest:
      type: object
      properties:
        bankAccountId:
          type: string
          format: uuid
        bankTransactionIds:
          type: array
          description: Bank transaction ids (list_bank_transactions' id) to include.
          items:
            type: string
            format: uuid
          maxItems: 500
          nullable: true
        lineIds:
          type: array
          items:
            type: string
            maxLength: 255
          maxItems: 500
          nullable: true
        note:
          type: string
          maxLength: 2000
          nullable: true
        period:
          type: integer
          format: int32
          maximum: 12
          minimum: 1
        year:
          type: integer
          format: int32
          maximum: 9998
          minimum: 1900
      required:
      - bankAccountId
      - period
      - year
    CreateUploadRequest:
      type: object
      properties:
        analyze:
          type: boolean
          description: false keeps the file from document analysis where the company
            has it switched on; it cannot switch analysis on. Default true.
          nullable: true
        association:
          $ref: "#/components/schemas/AssociationInput"
        displayName:
          type: string
          maxLength: 255
        mimeType:
          type: string
          maxLength: 255
        sizeBytes:
          type: integer
          format: int64
      required:
      - association
      - displayName
      - mimeType
      - sizeBytes
    CreateWebhookRequest:
      type: object
      properties:
        description:
          type: string
          maxLength: 500
          nullable: true
        eventTypes:
          type: array
          items:
            type: string
            maxLength: 100
          maxItems: 100
          nullable: true
        url:
          type: string
          maxLength: 2048
      required:
      - url
    DataFreshnessResponse:
      type: object
      description: "How fresh a company's ERP data is, and what recently failed."
      properties:
        companyId:
          type: string
          format: uuid
        currentYear:
          type: integer
          format: int32
          description: The current ledger's accounting year.
          nullable: true
        datasets:
          type: array
          description: "Per imported dataset type (gl_transactions, accounts, dimensions,\
            \ …)."
          items:
            $ref: "#/components/schemas/Dataset"
        erpSystem:
          type: string
          description: The ERP the current ledger is connected to; null when none.
          nullable: true
        fetchJobs:
          type: array
          description: "Per ERP fetch kind: gl_fetch, master_data_sync, subledger_sync."
          items:
            $ref: "#/components/schemas/FetchJob"
        lastGlFetchAt:
          type: string
          format: date-time
          description: When general-ledger data was last fetched into the current
            ledger.
          nullable: true
        recentFailures:
          type: array
          description: "Failed or expired fetches and failed imports of the last 30\
            \ days, newest first. A general-ledger fetch year no worker finished within\
            \ its limit is listed as expired."
          items:
            $ref: "#/components/schemas/Failure"
        subLedgerSync:
          $ref: "#/components/schemas/SubLedgerSync"
      required:
      - companyId
      - datasets
      - fetchJobs
      - recentFailures
      - subLedgerSync
    Dataset:
      type: object
      description: "Per imported dataset type (gl_transactions, accounts, dimensions,\
        \ …)."
      properties:
        importType:
          type: string
        lastCompletedAt:
          type: string
          format: date-time
          nullable: true
        lastCompletedYear:
          type: integer
          format: int32
          nullable: true
        lastFailedAt:
          type: string
          format: date-time
          nullable: true
        lastFailureMessage:
          type: string
          nullable: true
        lastRowsFailed:
          type: integer
          format: int64
          description: Rows the last completed import rejected.
          nullable: true
        lastRowsInserted:
          type: integer
          format: int64
          nullable: true
        lastRowsUpdated:
          type: integer
          format: int64
          nullable: true
      required:
      - importType
    DeadlineResponse:
      type: object
      description: One upcoming regulatory deadline.
      properties:
        category:
          type: string
          enum:
          - VAT
          - PAYROLL
          - TAX_RETURN
          x-extensible-enum: true
        countryCode:
          type: string
          description: Always NO.
        dueDate:
          type: string
          format: date
          description: "The effective due date: the statutory date rolled to the next\
            \ business day."
        id:
          type: string
          description: "Stable id, e.g. vat-2026-T3, amelding-2026-05, skattemelding-2025."
        kind:
          type: string
          description: "VAT_TERM (bi-monthly MVA term), VAT_MONTHLY, VAT_ANNUAL (å\
            rsterminoppgave), A_MELDING (payroll), TAX_RETURN (skattemelding)."
          enum:
          - VAT_TERM
          - VAT_MONTHLY
          - VAT_ANNUAL
          - A_MELDING
          - TAX_RETURN
          x-extensible-enum: true
        reportingPeriodEnd:
          type: string
          format: date
          description: Last day of the reported period (inclusive).
        reportingPeriodStart:
          type: string
          format: date
        reportingYear:
          type: integer
          format: int32
          description: The year the reported period belongs to.
        term:
          type: integer
          format: int32
          description: "VAT_TERM: term 1-6; VAT_MONTHLY and A_MELDING: month 1-12."
          nullable: true
      required:
      - category
      - countryCode
      - dueDate
      - id
      - kind
      - reportingPeriodEnd
      - reportingPeriodStart
      - reportingYear
    DeletionRequest:
      type: object
      properties:
        ids:
          type: array
          items:
            type: string
        year:
          type: integer
          format: int32
      required:
      - ids
      - year
    DeletionResponse:
      type: object
      description: "Confirmation of a deletion: the resource's id, DELETED, and when\
        \ it was deleted. A repeated delete of a soft-deleted resource answers the\
        \ same, with the first deletion's time."
      properties:
        deletedAt:
          type: string
          format: date-time
          description: When the resource was deleted.
        id:
          type: string
          format: uuid
          description: The deleted resource's id.
        status:
          type: string
          enum:
          - DELETED
          example: DELETED
          x-extensible-enum: true
      required:
      - deletedAt
      - id
      - status
    DimensionsImportRequest:
      type: object
      properties:
        dimensions:
          type: array
          items:
            $ref: "#/components/schemas/MasterLine"
      required:
      - dimensions
    DocumentAssociation:
      type: object
      description: "A document's connection to an account (for a period, a year or\
        \ in general), a general-ledger line, an opening balance, a voucher, the company,\
        \ a reconciliation run or an ERP ledger. type says which one target field\
        \ is set; the others are null. A removed connection keeps its row: detachedAt\
        \ says when."
      properties:
        accountId:
          type: string
          format: uuid
          description: "ACCOUNT: the account (accountId, one per accounting year)."
          nullable: true
        accountNumber:
          type: string
          description: "ACCOUNT: the account's number."
          example: "1920"
          nullable: true
        companyId:
          type: string
          format: uuid
          description: "COMPANY: the company (the document's own)."
          nullable: true
        connectionId:
          type: string
          format: uuid
          description: "The connection's id: what unlink_document takes."
        createdAt:
          type: string
          format: date-time
          description: When the connection was made.
        createdBy:
          type: string
          format: uuid
          description: Who made the connection (a user or a service account).
        detachReason:
          type: string
          description: "Why it was removed: REMOVED (someone disconnected it), REPLACED\
            \ (its periods were changed in the app) or TARGET_REMOVED (what it named\
            \ no longer exists). Null while active."
          enum:
          - REMOVED
          - REPLACED
          - TARGET_REMOVED
          nullable: true
          x-extensible-enum: true
        detachedAt:
          type: string
          format: date-time
          description: When it was removed; null while it is active.
          nullable: true
        documentId:
          type: string
          format: uuid
          description: The document's id.
        laterYears:
          type: boolean
          description: Also counts on the account with the same number in later years
            (core's laterYears).
        ledgerId:
          type: string
          format: uuid
          description: "ERP_LEDGER: the ledger's ledgerId."
          nullable: true
        lineId:
          type: string
          description: "GL_LINE: the general-ledger line's lineId."
          nullable: true
        openingBalanceId:
          type: string
          description: "OPENING_BALANCE: the opening balance's openingBalanceId."
          nullable: true
        period:
          type: integer
          format: int32
          description: "PERIOD, RANGE and OPEN: the period it starts in."
          nullable: true
        periodTo:
          type: integer
          format: int32
          description: "RANGE: its last period."
          nullable: true
        periodType:
          type: string
          description: "PERIOD, RANGE and OPEN: the cadence of period (the account's\
            \ own)."
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          nullable: true
          x-extensible-enum: true
        runId:
          type: string
          format: uuid
          description: "RECON_RUN: the reconciliation run's runId."
          nullable: true
        scope:
          type: string
          description: "Which periods the connection counts for: GENERAL (every period,\
            \ until removed), YEAR (the year), PERIOD (one period), RANGE (year/period\
            \ to yearTo/periodTo) or OPEN (from the period on). Null for a connection\
            \ that carries no period (the company, a run, a ledger)."
          enum:
          - GENERAL
          - YEAR
          - PERIOD
          - RANGE
          - OPEN
          nullable: true
          x-extensible-enum: true
        type:
          type: string
          description: "What the document is connected to, which says the one target\
            \ field that is set. OTHER: a connection whose target was removed (detached,\
            \ nothing left to name)."
          enum:
          - ACCOUNT
          - GL_LINE
          - OPENING_BALANCE
          - VOUCHER
          - COMPANY
          - RECON_RUN
          - ERP_LEDGER
          - OTHER
          example: ACCOUNT
          x-extensible-enum: true
        voucherKey:
          type: string
          description: "VOUCHER: the voucher's voucherKey."
          nullable: true
        year:
          type: integer
          format: int32
          description: "YEAR, PERIOD, RANGE and OPEN: the accounting year it starts\
            \ in."
          nullable: true
        yearTo:
          type: integer
          format: int32
          description: "RANGE: the accounting year of its last period."
          nullable: true
      required:
      - connectionId
      - createdAt
      - createdBy
      - documentId
      - laterYears
      - type
    DocumentResponse:
      type: object
      description: "A document. Download the binary via GET /v1/documents/{id}/download-url."
      properties:
        association:
          $ref: "#/components/schemas/Association"
        associations:
          type: array
          description: "Everything the document is attached to, oldest first: the\
            \ company, vouchers (voucher), accounts (with the period for period-scoped\
            \ account documents), reconciliation runs (recon_run) and ERP ledgers\
            \ (erp_ledger)."
          items:
            $ref: "#/components/schemas/AttachedTo"
        companyId:
          type: string
          format: uuid
        createdAt:
          type: string
          format: date-time
        createdBy:
          type: string
          format: uuid
          description: The identity that uploaded it (a user or a service account).
        displayName:
          type: string
          example: Faktura 2026-042.pdf
        id:
          type: string
          format: uuid
          description: The document's stable identifier.
        mimeType:
          type: string
          example: application/pdf
          nullable: true
        organizationId:
          type: string
          format: uuid
        sizeBytes:
          type: integer
          format: int64
          nullable: true
        updatedAt:
          type: string
          format: date-time
      required:
      - associations
      - companyId
      - createdAt
      - createdBy
      - displayName
      - id
      - organizationId
      - updatedAt
    DocumentUploadResponse:
      type: object
      description: "An upload slot: PUT the binary to the signed URL, then POST /complete."
      properties:
        displayName:
          type: string
        documentId:
          type: string
          format: uuid
          description: The id the document will have once completed.
        mimeType:
          type: string
        sizeBytes:
          type: integer
          format: int64
        upload:
          $ref: "#/components/schemas/Upload"
      required:
      - displayName
      - documentId
      - mimeType
      - sizeBytes
      - upload
    DownloadUrlResponse:
      type: object
      description: A short-lived signed URL for the binary. Fetch promptly; request
        a fresh one when it expires.
      properties:
        expiresAt:
          type: string
          format: date-time
        filename:
          type: string
          example: Faktura 2026-042.pdf
        url:
          type: string
      required:
      - expiresAt
      - filename
      - url
    EffectiveAccessAccountGrant:
      type: object
      description: A role on one account code.
      properties:
        accountCode:
          type: string
          example: "1920"
        role:
          type: string
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: ADMIN
          x-extensible-enum: true
      required:
      - accountCode
      - role
    EffectiveAccessResponse:
      type: object
      description: "One company's effective access for a user, resolved per resource,\
        \ with every grant behind it."
      properties:
        accountGrants:
          type: array
          description: "Roles on single account codes that exceed unrestrictedRole,\
            \ sorted by code."
          items:
            $ref: "#/components/schemas/EffectiveAccessAccountGrant"
        companyId:
          type: string
          format: uuid
        role:
          type: string
          description: "The highest role the user holds anywhere in the company: what\
            \ they can do somewhere in it, not on a given account."
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: ACCOUNTANT
          x-extensible-enum: true
        sources:
          type: array
          description: "Every grant that reaches the company: each policy rule, or\
            \ the organization-admin reach. Exactly one is decisive."
          items:
            $ref: "#/components/schemas/EffectiveAccessSource"
        templateGrants:
          type: array
          description: "Roles on a template's accounts that exceed unrestrictedRole,\
            \ in core's template order."
          items:
            $ref: "#/components/schemas/EffectiveAccessTemplateGrant"
        unrestrictedRole:
          type: string
          description: The role on every account of the company. Null when every grant
            is restricted to templates or account codes.
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: VIEWER
          nullable: true
          x-extensible-enum: true
      required:
      - accountGrants
      - companyId
      - role
      - sources
      - templateGrants
    EffectiveAccessSource:
      type: object
      description: "One grant behind a company's access: which policy rule gave it\
        \ and how the policy reached the user, or the organization-admin reach."
      properties:
        accountCodes:
          type: array
          description: The account codes the rule covers; empty unless ACCOUNTS.
          items:
            type: string
        decisive:
          type: boolean
          description: True on the single source whose role is the company's effective
            role.
        groupId:
          type: string
          format: uuid
          description: The group the policy is assigned to. Set only for GROUP.
          nullable: true
        groupName:
          type: string
          nullable: true
        kind:
          type: string
          description: "How the access reached the user: DIRECT (the policy is assigned\
            \ to them), GROUP (assigned to a group they belong to), ORG_ADMIN (an\
            \ ADMIN membership of the organization or a parent organization, no policy)."
          enum:
          - DIRECT
          - GROUP
          - ORG_ADMIN
          example: DIRECT
          x-extensible-enum: true
        policyId:
          type: string
          format: uuid
          description: The granting policy. Null for ORG_ADMIN.
          nullable: true
        policyName:
          type: string
          nullable: true
        portfolioId:
          type: string
          format: uuid
          description: The portfolio the rule points at. Set only for scopeType PORTFOLIO.
          nullable: true
        portfolioName:
          type: string
          nullable: true
        resourceScope:
          type: string
          description: What the rule granted the role over.
          enum:
          - ALL
          - TEMPLATES
          - ACCOUNTS
          example: ALL
          x-extensible-enum: true
        role:
          type: string
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: ACCOUNTANT
          x-extensible-enum: true
        scopeType:
          type: string
          description: What the rule points at. Null for ORG_ADMIN.
          enum:
          - COMPANY
          - ORGANIZATION
          - PORTFOLIO
          nullable: true
          x-extensible-enum: true
        templateTypes:
          type: array
          description: The templates the rule covers; empty unless TEMPLATES.
          items:
            type: string
            enum:
            - VAT
            - PAYROLL
            - ASSETS
            - BANK
            - SIMPLE_BANK
            - ACCRUALS
            - GENERAL_LEDGER_BALANCE
            - GENERAL_LEDGER_BALANCE_PRO
            - GENERAL_LEDGER
            - SUB_LEDGER
            x-extensible-enum: true
        validFrom:
          type: string
          format: date-time
          description: A time-bound grant's first moment (inclusive). Null for an
            open-ended grant.
          nullable: true
        validTo:
          type: string
          format: date-time
          description: "A time-bound grant's end (exclusive): the access stops then,\
            \ by itself. Null for an open-ended grant."
          nullable: true
      required:
      - accountCodes
      - decisive
      - kind
      - resourceScope
      - role
      - templateTypes
    EffectiveAccessTemplateGrant:
      type: object
      description: A role on every account of one template.
      properties:
        role:
          type: string
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: ACCOUNTANT
          x-extensible-enum: true
        templateType:
          type: string
          enum:
          - VAT
          - PAYROLL
          - ASSETS
          - BANK
          - SIMPLE_BANK
          - ACCRUALS
          - GENERAL_LEDGER_BALANCE
          - GENERAL_LEDGER_BALANCE_PRO
          - GENERAL_LEDGER
          - SUB_LEDGER
          example: BANK
          x-extensible-enum: true
      required:
      - role
      - templateType
    Failure:
      type: object
      description: "Failed or expired fetches and failed imports of the last 30 days,\
        \ newest first. A general-ledger fetch year no worker finished within its\
        \ limit is listed as expired."
      properties:
        at:
          type: string
          format: date-time
        failureType:
          type: string
          nullable: true
        message:
          type: string
          description: "The import's own message, when it left one."
          nullable: true
        source:
          type: string
          enum:
          - FETCH_JOB
          - DATASET
          x-extensible-enum: true
        status:
          type: string
          description: "FAILED, or EXPIRED for a fetch that never finished."
          enum:
          - FAILED
          - EXPIRED
          x-extensible-enum: true
        type:
          type: string
          description: "For FETCH_JOB the fetch kind, as fetchJobs[].jobType names\
            \ it (GL_FETCH, …); for DATASET the dataset's import type, as datasets[].importType\
            \ names it."
          nullable: true
        year:
          type: integer
          format: int32
          nullable: true
      required:
      - at
      - source
      - status
    FetchJob:
      type: object
      description: "Per ERP fetch kind: gl_fetch, master_data_sync, subledger_sync."
      properties:
        jobType:
          type: string
          enum:
          - GL_FETCH
          - MASTER_DATA_SYNC
          - SUBLEDGER_SYNC
          x-extensible-enum: true
        lastSucceededAt:
          type: string
          format: date-time
          nullable: true
        lastSucceededYear:
          type: integer
          format: int32
          description: The accounting year the last successful fetch covered (0 =
            not period-scoped).
          nullable: true
        latestFailureType:
          type: string
          nullable: true
        latestFinishedAt:
          type: string
          format: date-time
          nullable: true
        latestRequestedAt:
          type: string
          format: date-time
          nullable: true
        latestStatus:
          type: string
          description: "PENDING, ACKNOWLEDGED, RUNNING, COMPLETED, FAILED, EXPIRED\
            \ or SUPERSEDED; null when never ordered. A general-ledger fetch year\
            \ no worker finished within its limit reads EXPIRED, with latestFailureType\
            \ ClaimExpired."
          enum:
          - PENDING
          - ACKNOWLEDGED
          - RUNNING
          - COMPLETED
          - FAILED
          - EXPIRED
          - SUPERSEDED
          nullable: true
          x-extensible-enum: true
      required:
      - jobType
    FlagResponse:
      type: object
      description: "A flag marking an item for review. One flag per item: flagging\
        \ again returns the same flag."
      properties:
        accountNumber:
          type: string
          description: "The account number, for ACCOUNT flags."
          nullable: true
        createdAt:
          type: string
          format: date-time
          description: When the item was flagged.
        createdBy:
          type: string
          format: uuid
          description: Who flagged it.
          nullable: true
        createdByName:
          type: string
          description: Their name; null when none is on record. Never an e-mail address.
          nullable: true
        id:
          type: string
          format: uuid
          description: Flag id.
        itemType:
          type: string
          description: ACCOUNT | GL_LINE | ACCRUAL | OPENING_BALANCE | BANK_TRANSACTION.
          enum:
          - ACCOUNT
          - GL_LINE
          - ACCRUAL
          - OPENING_BALANCE
          - BANK_TRANSACTION
          example: GL_LINE
          x-extensible-enum: true
        subjectKey:
          $ref: "#/components/schemas/SubjectKey"
      required:
      - createdAt
      - id
      - itemType
      - subjectKey
    FxRateResponse:
      type: object
      description: "A reference exchange rate: rate units of quoteCurrency per 1 unit\
        \ of currency."
      properties:
        currency:
          type: string
          example: EUR
        date:
          type: string
          format: date
          description: The date asked for.
        found:
          type: boolean
          description: Whether a rate was found.
        quoteCurrency:
          type: string
          example: NOK
        rate:
          type: number
          description: quoteCurrency per 1 currency.
          example: 11.7215
          nullable: true
        rateDate:
          type: string
          format: date
          description: "The date of the published rate applied: the latest on or before\
            \ date (a weekend or holiday carries the previous banking day's rate forward)."
          nullable: true
        source:
          type: string
          description: "The provider that priced it (NORGES_BANK, ECB); absent when\
            \ the currencies are the same."
          enum:
          - NORGES_BANK
          - ECB
          nullable: true
          x-extensible-enum: true
      required:
      - currency
      - date
      - found
      - quoteCurrency
    GlEntry:
      type: object
      description: "One matched ledger post: a general-ledger line, or an opening-balance\
        \ row (an item of a split opening balance, or a whole opening balance nobody\
        \ has split)."
      properties:
        amount:
          type: number
          description: "The amount matched, in the group's currencyCode."
        lineId:
          type: string
          description: "The post's stable id: a GL line's lineId in list_general_ledger_lines,\
            \ or an opening-balance row's openingBalanceId in list_opening_balances."
        openingBalanceId:
          type: string
          description: "The opening-balance row's id (its openingBalanceId in list_opening_balances),\
            \ when postType is OPENING_BALANCE; null for a LINE."
          nullable: true
        postType:
          type: string
          description: "LINE: a general-ledger line. OPENING_BALANCE: an opening-balance\
            \ row."
          enum:
          - LINE
          - OPENING_BALANCE
          example: LINE
          x-extensible-enum: true
      required:
      - amount
      - lineId
      - postType
    GlLine:
      type: object
      description: One general-ledger line.
      properties:
        accountCode:
          type: string
          example: "3000"
        amount:
          type: string
          description: "Signed amount in the company's base currency, as a decimal\
            \ string (a JSON number is also accepted). At most four decimals."
          example: "-1250.0"
        description:
          type: string
          nullable: true
        dimensionKeys:
          type: array
          items:
            type: string
            nullable: true
          nullable: true
        exchangeRate:
          type: number
          nullable: true
        id:
          type: string
          description: Your stable id for this line; re-sending the same id updates
            it in place.
          example: INV-2025-000123-1
        lineDescription:
          type: string
          nullable: true
        partyKeys:
          type: array
          description: "The parties (customers, suppliers) the line is tagged with:\
            \ their partyKey."
          items:
            type: string
            description: "The parties (customers, suppliers) the line is tagged with:\
              \ their partyKey."
            nullable: true
          nullable: true
        period:
          type: integer
          format: int32
          description: Fiscal period 1–12.
          example: 3
        postedDate:
          type: string
          format: date
          nullable: true
        taxAmount:
          type: number
          nullable: true
        taxBase:
          type: number
          nullable: true
        taxCode:
          type: string
          description: The ERP's VAT code for the line.
          nullable: true
        taxPercentage:
          type: number
          nullable: true
        transactionAmount:
          type: number
          nullable: true
        transactionCurrencyCode:
          type: string
          example: NOK
          nullable: true
        transactionDate:
          type: string
          format: date
          nullable: true
        voucherKey:
          type: string
          description: "Your key for the voucher this line belongs to (the contract's\
            \ transactionId): the voucherKey general-ledger lines and vouchers return,\
            \ and the value a document's VOUCHER association takes."
          example: V-2025-0456
        voucherNo:
          type: string
          description: "The voucher number as shown to accountants (the contract's\
            \ transactionNo): the voucherNo general-ledger lines return."
          example: "456"
      required:
      - accountCode
      - amount
      - id
      - period
      - voucherKey
      - voucherNo
    GlLineResponse:
      type: object
      description: A general-ledger line.
      properties:
        accountNumber:
          type: string
          description: The account number this line is posted to.
          example: "3000"
        amount:
          type: number
          description: "Amount in the company's base currency (signed; debit positive).\
            \ On a bank's ledger account a payment out is a credit, so negative: the\
            \ same sign as the bank transaction."
        attachmentCount:
          type: integer
          format: int32
          description: Active ERP attachments (vedlegg) on the line's voucher.
        bankReconciliationStatus:
          type: string
          description: "Lines of a BANK account only (null on every other account):\
            \ the line's bank reconciliation state. UNRECONCILED = in no reconciliation\
            \ group; RECONCILED = in a live group against bank transactions; STALE\
            \ = in a group that needs review (matched data changed); CORRECTION /\
            \ MANUAL_CORRECTION = in a live group of ledger posts only, made by the\
            \ automatcher / by a person. A line in a live group (any status but UNRECONCILED\
            \ and STALE) is closed, as the bank approval and get_account_reconciliation\
            \ count it."
          enum:
          - UNRECONCILED
          - RECONCILED
          - STALE
          - CORRECTION
          - MANUAL_CORRECTION
          nullable: true
          x-extensible-enum: true
        baseCurrency:
          type: string
          description: The base/reporting currency.
          example: NOK
          nullable: true
        description:
          type: string
          description: Line description.
          nullable: true
        dimensionKeys:
          type: array
          description: "Keys of the dimension values (departments, projects, ...)\
            \ the line is tagged with."
          items:
            type: string
            description: "Keys of the dimension values (departments, projects, ...)\
              \ the line is tagged with."
        exchangeRate:
          type: number
          description: base = transactionAmount × exchangeRate.
          nullable: true
        lineId:
          type: string
          description: Stable line identifier (survives re-imports).
        partyKeys:
          type: array
          description: "The parties (customers, suppliers) the line is tagged with:\
            \ their partyKey, as list_sub_ledgers and list_open_items name them."
          items:
            type: string
            description: "The parties (customers, suppliers) the line is tagged with:\
              \ their partyKey, as list_sub_ledgers and list_open_items name them."
        period:
          type: integer
          format: int32
          description: Fiscal period 1–12.
        postedDate:
          type: string
          format: date
          description: Posting date (bokføringsdato).
          nullable: true
        reconciliationGroupId:
          type: string
          format: uuid
          description: "The bank reconciliation group the line is in (get_reconciliation's\
            \ reconciliationGroupId), stale or not; null when it is in none or is\
            \ not a BANK account's line."
          nullable: true
        settlementId:
          type: string
          format: uuid
          description: The settlement the line belongs to (the newest one within the
            line's accounting year when there are several); absent when open.
          nullable: true
        settlementStatus:
          type: string
          description: "Ledger settlement (utligning) state only: OPEN = in no settlement;\
            \ SETTLED = in a settlement whose difference is below 0.05 (rounding);\
            \ PARTIAL = in a settlement that leaves a remainder. A bank account's\
            \ lines are closed by bank reconciliation groups, not by settlements:\
            \ read bankReconciliationStatus for them."
          enum:
          - OPEN
          - SETTLED
          - PARTIAL
          x-extensible-enum: true
        settlementType:
          type: string
          description: "Who made the settlement: AUTO (the automatcher) or MANUAL;\
            \ absent when open."
          enum:
          - AUTO
          - MANUAL
          nullable: true
          x-extensible-enum: true
        sourceLineId:
          type: string
          description: "The id the line was pushed with through the API imports, when\
            \ it was; absent for lines fetched from an ERP."
          nullable: true
        taxAmount:
          type: number
          description: "VAT amount on the line, base currency."
          nullable: true
        taxCode:
          type: string
          description: The ERP's VAT code for the line.
          nullable: true
        transactionAmount:
          type: number
          description: Amount in the original document currency.
          nullable: true
        transactionCurrency:
          type: string
          description: The document currency.
          example: EUR
          nullable: true
        transactionDate:
          type: string
          format: date
          description: Document/transaction date (bilagsdato).
          nullable: true
        voucherKey:
          type: string
          description: "The ERP's key for the line's voucher (erp.gl_line.transaction_id):\
            \ the value a document's VOUCHER association takes, on upload and as listDocuments'\
            \ associationId. Not the voucher number, though some ERPs use the same\
            \ value; absent when the ERP sent none."
          nullable: true
        voucherNo:
          type: string
          description: The voucher (bilag) number this line belongs to.
          nullable: true
        year:
          type: integer
          format: int32
          description: Accounting year.
      required:
      - accountNumber
      - amount
      - attachmentCount
      - dimensionKeys
      - lineId
      - partyKeys
      - period
      - settlementStatus
      - year
    GlLineTotals:
      type: object
      description: Sums over every line the filters match.
      nullable: true
      properties:
        credit:
          type: number
          description: "Sum of the negative (credit) amounts as a positive number,\
            \ in the base currency."
        debit:
          type: number
          description: "Sum of the positive (debit) amounts, in the base currency."
        lineCount:
          type: integer
          format: int64
          description: Number of lines.
        net:
          type: number
          description: "debit − credit: the signed sum of every amount."
      required:
      - credit
      - debit
      - lineCount
      - net
    GlLinesImportRequest:
      type: object
      properties:
        lines:
          type: array
          items:
            $ref: "#/components/schemas/GlLine"
        mode:
          type: string
          description: MERGE (default; any case is accepted). REPLACE is not available
            yet.
          enum:
          - MERGE
          nullable: true
        year:
          type: integer
          format: int32
      required:
      - lines
      - year
    GlLinesResponse:
      type: object
      description: "A page of general-ledger lines, with totals over every line the\
        \ filters match."
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/GlLineResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
        totals:
          $ref: "#/components/schemas/GlLineTotals"
      required:
      - data
      - pagination
    GlMapping:
      type: object
      description: "A GL mapping: the GL account a bank account fed between two days."
      properties:
        glAccountNumber:
          type: string
          description: The GL account number the bank account fed.
          example: "1920"
        validFrom:
          type: string
          format: date
          description: The first day the mapping holds; null when it has no start
            (from the account's first line).
          nullable: true
        validTo:
          type: string
          format: date
          description: The last day the mapping holds; null while it is in force.
          nullable: true
      required:
      - glAccountNumber
    ImportReadinessResponse:
      type: object
      description: "What an API-managed company already holds, and what to import\
        \ next."
      properties:
        accountingSystem:
          type: string
          description: "The accounting system the current ledger is bound to, if any."
          nullable: true
        apiManaged:
          type: boolean
          description: Whether the company's current ledger is bound to the Api accounting
            system. Imports are refused (409 company_not_api_managed) while this is
            false.
        blockers:
          type: array
          description: "What prevents importing right now: COMPANY_NOT_API_MANAGED,\
            \ NO_CURRENT_LEDGER, NO_ACCOUNTS (the current year has no chart yet)."
          enum:
          - COMPANY_NOT_API_MANAGED
          - NO_CURRENT_LEDGER
          - NO_ACCOUNTS
          items:
            type: string
            description: "What prevents importing right now: COMPANY_NOT_API_MANAGED,\
              \ NO_CURRENT_LEDGER, NO_ACCOUNTS (the current year has no chart yet)."
            enum:
            - COMPANY_NOT_API_MANAGED
            - NO_CURRENT_LEDGER
            - NO_ACCOUNTS
            x-extensible-enum: true
          x-extensible-enum: true
        companyId:
          type: string
          format: uuid
        currentYear:
          type: integer
          format: int32
          description: The current accounting year.
          nullable: true
        dimensions:
          type: integer
          format: int64
          description: Dimension values the company holds (company-wide).
        nextStep:
          type: string
          description: BIND_API_ACCOUNTING_SYSTEM | IMPORT_ACCOUNTS | IMPORT_OPENING_BALANCES
            | IMPORT_GENERAL_LEDGER_LINES | READY
          enum:
          - BIND_API_ACCOUNTING_SYSTEM
          - IMPORT_ACCOUNTS
          - IMPORT_OPENING_BALANCES
          - IMPORT_GENERAL_LEDGER_LINES
          - READY
          example: IMPORT_ACCOUNTS
          x-extensible-enum: true
        subLedgers:
          type: integer
          format: int64
          description: Sub-ledgers the company holds (company-wide).
        warnings:
          type: array
          description: "What does not block but deserves attention: UNMAPPED_ACCOUNTS\
            \ (accounts without a standard-account mapping do not take part in reconciliation\
            \ rules)."
          enum:
          - UNMAPPED_ACCOUNTS
          items:
            type: string
            description: "What does not block but deserves attention: UNMAPPED_ACCOUNTS\
              \ (accounts without a standard-account mapping do not take part in reconciliation\
              \ rules)."
            enum:
            - UNMAPPED_ACCOUNTS
            x-extensible-enum: true
          x-extensible-enum: true
        years:
          type: array
          description: "One entry per accounting year that has an API-managed ledger,\
            \ oldest first."
          items:
            $ref: "#/components/schemas/Year"
      required:
      - apiManaged
      - blockers
      - companyId
      - dimensions
      - nextStep
      - subLedgers
      - warnings
      - years
    ImportResponse:
      type: object
      description: An import or correction request. Poll until status is SUCCEEDED
        or FAILED.
      properties:
        companyId:
          type: string
          format: uuid
          description: The company the data was imported into.
        createdAt:
          type: string
          format: date-time
        datasetId:
          type: string
          format: uuid
          description: The dataset id recorded on every row this import touched (provenance).
        failureReason:
          type: string
          description: "Why the import failed, present when status is FAILED: ingest_unavailable,\
            \ ingest_rejected: <detail>, staging_failed: <detail>, promotion_failed:\
            \ <detail>, promotion_missing, payload_expired, job_expired, internal_error,\
            \ api_client_inactive, company_unavailable, company_not_api_managed, company_read_only\
            \ (the request's preconditions no longer held when its job ran; company_read_only:\
            \ the organization was terminated), or a corrections reason such as lines_in_use."
          nullable: true
        finishedAt:
          type: string
          format: date-time
          nullable: true
        id:
          type: string
          format: uuid
          description: The import's stable identifier.
        jobId:
          type: string
          format: uuid
          description: "The job running this import; GET /v1/jobs/{jobId} shows the\
            \ same lifecycle."
        kind:
          type: string
          description: What was imported or corrected. The *_DELETION kinds are corrections.
          enum:
          - ACCOUNTS
          - DIMENSIONS
          - SUB_LEDGERS
          - OPENING_BALANCES
          - GENERAL_LEDGER_LINES
          - OPEN_ITEMS
          - TRIAL_BALANCE
          - ACCOUNT_DELETION
          - DIMENSION_DELETION
          - SUB_LEDGER_DELETION
          - OPENING_BALANCES_DELETION
          - GENERAL_LEDGER_LINES_DELETION
          x-extensible-enum: true
        lineCount:
          type: integer
          format: int32
          description: Lines accepted in the request.
        mode:
          type: string
          description: MERGE for general-ledger lines (replace is not available yet);
            the snapshot mode for open items; absent for other kinds.
          enum:
          - MERGE
          - BASELINE
          - INCREMENTAL
          - FULL
          - FULL_REFRESH
          nullable: true
          x-extensible-enum: true
        result:
          type: object
          description: "Kind-specific outcome details (created dimension keys, refused\
            \ deletions, ...)."
        rowsDeleted:
          type: integer
          format: int64
          nullable: true
        rowsDiscovered:
          type: integer
          format: int64
          nullable: true
        rowsFailed:
          type: integer
          format: int64
          nullable: true
        rowsInserted:
          type: integer
          format: int64
          nullable: true
        rowsUpdated:
          type: integer
          format: int64
          nullable: true
        rowsValid:
          type: integer
          format: int64
          nullable: true
        sampleErrors:
          type: array
          description: "Up to 100 line-level errors, 'line N: message', once the import\
            \ ran."
          items:
            type: string
            description: "Up to 100 line-level errors, 'line N: message', once the\
              \ import ran."
        startedAt:
          type: string
          format: date-time
          nullable: true
        status:
          type: string
          description: SUCCEEDED and FAILED are terminal; failureReason says why.
          enum:
          - QUEUED
          - RUNNING
          - SUCCEEDED
          - FAILED
          example: QUEUED
          x-extensible-enum: true
        year:
          type: integer
          format: int32
          description: The accounting year the data belongs to; absent for company-scoped
            kinds.
          nullable: true
      required:
      - companyId
      - createdAt
      - datasetId
      - id
      - jobId
      - kind
      - lineCount
      - result
      - sampleErrors
      - status
    InheritableBoolean:
      type: object
      description: "Whether finished runs approve the module's reconciled accounts\
        \ without a person. PAYROLL never inherits the company's: it stays off until\
        \ switched on for PAYROLL. The currency controls never approve: always false."
      properties:
        inherited:
          type: boolean
        value:
          type: boolean
      required:
      - inherited
      - value
    InheritableDecimal:
      type: object
      description: NOK; standard 100.
      properties:
        inherited:
          type: boolean
        value:
          type: number
      required:
      - inherited
      - value
    InheritableInteger:
      type: object
      description: "The first-pass window in days. BANK inherits the bank matcher's\
        \ own 3 days (the days a bank line and a ledger line of the same amount may\
        \ be apart), never the company's window. SIMPLE_BANK, BALANCE, ASSETS, VAT,\
        \ PAYROLL and the currency controls match no lines: the company's window is\
        \ shown, and only it is accepted back."
      properties:
        inherited:
          type: boolean
        value:
          type: integer
          format: int32
      required:
      - inherited
      - value
    IntercompanyAccountLink:
      type: object
      description: "An account, or part of one, reconciled on a line."
      properties:
        accountDescription:
          type: string
          nullable: true
        accountNumber:
          type: string
        dimensionKey:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
        lineId:
          type: string
          format: uuid
          description: The intercompany reconciliation line the slice is on (a uuid;
            not a GL lineId).
        method:
          type: string
          description: "ACCOUNT (the whole account), SUBLEDGER (one sub-ledger party)\
            \ or DIMENSION."
          enum:
          - ACCOUNT
          - SUBLEDGER
          - DIMENSION
          x-extensible-enum: true
        partyKey:
          type: string
          description: "The party of a SUBLEDGER link: its partyKey."
          nullable: true
      required:
      - accountNumber
      - id
      - lineId
      - method
    IntercompanyCounterpartyLine:
      type: object
      description: A line on the counterparty's side of the pair.
      properties:
        lineType:
          type: string
          enum:
          - OPERATING
          - LOAN
          - INTEREST
          - GROUP_CONTRIBUTION
          - DIVIDEND
          - OTHER
          x-extensible-enum: true
        name:
          type: string
          nullable: true
        pairingKey:
          type: string
          format: uuid
      required:
      - lineType
      - pairingKey
    IntercompanyDefinition:
      type: object
      description: A company's link to one counterparty in a group.
      properties:
        accounts:
          type: array
          items:
            $ref: "#/components/schemas/IntercompanyAccountLink"
        active:
          type: boolean
          description: A deactivated link is kept with its history and still owns
            its accounts.
        allowPartialSettlement:
          type: boolean
        basis:
          type: string
          description: What is compared; BALANCE.
        companyGroupId:
          type: string
          format: uuid
        companyId:
          type: string
          format: uuid
        counterparty:
          $ref: "#/components/schemas/IntercompanyGroupMember"
        counterpartyLines:
          type: array
          description: "The counterparty's lines, from its link back to this company,\
            \ to pair with by pairingKey. Its accounts are not shown."
          items:
            $ref: "#/components/schemas/IntercompanyCounterpartyLine"
        groupName:
          type: string
        id:
          type: string
          format: uuid
        lines:
          type: array
          items:
            $ref: "#/components/schemas/IntercompanyLine"
        mirrorExists:
          type: boolean
          description: Whether the counterparty has an active link back to this company.
        signConvention:
          type: string
          description: SUM_ZERO (the two balances cancel out) or SAME_SIGN.
        version:
          type: string
          description: "Pass back as expectedVersion to change the link, its lines\
            \ or its accounts."
      required:
      - accounts
      - active
      - allowPartialSettlement
      - basis
      - companyGroupId
      - companyId
      - counterparty
      - counterpartyLines
      - groupName
      - id
      - lines
      - mirrorExists
      - signConvention
      - version
    IntercompanyDefinitions:
      type: object
      properties:
        companyId:
          type: string
          format: uuid
        data:
          type: array
          items:
            $ref: "#/components/schemas/IntercompanyDefinition"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - companyId
      - data
      - pagination
    IntercompanyGroup:
      type: object
      description: A group of companies that trade with each other.
      properties:
        active:
          type: boolean
        cadence:
          type: string
          description: How often the counterparties reconcile (a period type).
        id:
          type: string
          format: uuid
        members:
          type: array
          items:
            $ref: "#/components/schemas/IntercompanyGroupMember"
        name:
          type: string
        toleranceAmount:
          type: number
          description: A difference up to this amount still reconciles.
        tolerancePct:
          type: number
          description: A difference up to this percentage still reconciles.
          nullable: true
      required:
      - active
      - cadence
      - id
      - members
      - name
      - toleranceAmount
    IntercompanyGroupMember:
      type: object
      description: "A company of the organization, or an external party."
      properties:
        companyId:
          type: string
          format: uuid
          description: The member company; absent for an external party.
          nullable: true
        countryCode:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
        name:
          type: string
        onPlatform:
          type: boolean
          description: Whether the member is a company in Accountflow.
        orgNumber:
          type: string
          description: Organization number.
          nullable: true
        thisCompany:
          type: boolean
          description: Whether the member is the company asked about.
      required:
      - id
      - name
      - onPlatform
      - thisCompany
    IntercompanyGroups:
      type: object
      properties:
        companyId:
          type: string
          format: uuid
        data:
          type: array
          items:
            $ref: "#/components/schemas/IntercompanyGroup"
        pagination:
          $ref: "#/components/schemas/Pagination"
        version:
          type: string
          description: Pass back as expectedVersion to link a counterparty.
      required:
      - companyId
      - data
      - pagination
      - version
    IntercompanyLine:
      type: object
      description: A reconciliation line of a counterparty link.
      properties:
        id:
          type: string
          format: uuid
        lineType:
          type: string
          description: "OPERATING, LOAN, INTEREST, GROUP_CONTRIBUTION, DIVIDEND or\
            \ OTHER."
          enum:
          - OPERATING
          - LOAN
          - INTEREST
          - GROUP_CONTRIBUTION
          - DIVIDEND
          - OTHER
          x-extensible-enum: true
        name:
          type: string
          nullable: true
        pairingKey:
          type: string
          format: uuid
          description: Pairs this line with the counterparty's line carrying the same
            key.
        sortOrder:
          type: integer
          format: int32
      required:
      - id
      - lineType
      - pairingKey
      - sortOrder
    JobResource:
      type: object
      description: The resource a job runs.
      nullable: true
      properties:
        companyId:
          type: string
          format: uuid
          description: The company the resource belongs to.
        id:
          type: string
          format: uuid
          description: "The resource's id: for an import, importId."
        type:
          type: string
          description: The resource's type. New types may appear; ignore those you
            do not know.
          enum:
          - IMPORT
          example: IMPORT
          x-extensible-enum: true
      required:
      - companyId
      - id
      - type
    JobResponse:
      type: object
      description: "An asynchronous job. Poll GET /v1/jobs/{jobId} until status is\
        \ terminal."
      properties:
        createdAt:
          type: string
          format: date-time
        error:
          type: string
          description: "Failure summary, present when status is FAILED."
          nullable: true
        finishedAt:
          type: string
          format: date-time
          nullable: true
        id:
          type: string
          format: uuid
          description: The job's stable identifier.
        params:
          type: object
          description: "The parameters the job was submitted with. Free-form JSON,\
            \ shaped by the job type."
        resource:
          $ref: "#/components/schemas/JobResource"
        result:
          type: object
          description: "Result document, present when status is SUCCEEDED. Free-form\
            \ JSON, shaped by the job type."
          nullable: true
        startedAt:
          type: string
          format: date-time
          nullable: true
        status:
          type: string
          description: "The job's lifecycle state; SUCCEEDED, FAILED and EXPIRED are\
            \ terminal."
          enum:
          - PENDING
          - RUNNING
          - SUCCEEDED
          - FAILED
          - EXPIRED
          example: PENDING
          x-extensible-enum: true
        type:
          type: string
          description: "The job type, e.g. import.<kind> for imports and corrections."
          example: import.general_ledger_lines
      required:
      - createdAt
      - id
      - params
      - status
      - type
    LedgerAccountResponse:
      type: object
      description: An account in the company's chart of accounts for one accounting
        year.
      properties:
        accountId:
          type: string
          format: uuid
          description: "This accounting year's account: the id the account-scoped\
            \ reads, the settings routes and the bulk account mapping take. It identifies\
            \ one year's account only — every accounting year has a new one — so keep\
            \ accountNumber + year as the stable key."
        accountNumber:
          type: string
          description: The account number as it exists in the ERP.
          example: "3000"
        category:
          type: string
          description: ERP-supplied category.
          nullable: true
        controller:
          $ref: "#/components/schemas/PersonRef"
        currencyCode:
          type: string
          description: Account currency.
          example: NOK
          nullable: true
        documentationRequired:
          type: boolean
          description: "Whether a reconciliation of this account must be documented:\
            \ the account's own setting, else its standard account's default, else\
            \ false."
        hasActivity:
          type: boolean
          description: Whether the account has any GL activity this year.
        name:
          type: string
          description: Account name.
          example: "Salgsinntekt, avgiftspliktig"
          nullable: true
        owner:
          $ref: "#/components/schemas/PersonRef"
        postingType:
          type: string
          description: "How the account's balance is translated to a reporting currency\
            \ (IAS 21), as a person set it in the app; the currency revaluation control\
            \ reads it. Null when none is set."
          enum:
          - MONETARY
          - NON_MONETARY_HISTORICAL_COST
          - NON_MONETARY_FAIR_VALUE
          - EQUITY
          - PROFIT_AND_LOSS
          example: MONETARY
          nullable: true
          x-extensible-enum: true
        reconciliationFrequency:
          type: string
          description: "How often the account is reconciled (MONTHLY, BIMONTHLY, QUARTERLY,\
            \ TERTIARY, HALF_YEARLY, YEARLY); absent = no reconciliation cadence."
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          example: MONTHLY
          nullable: true
          x-extensible-enum: true
        saftCode:
          type: string
          description: "The mapped Norwegian SAF-T standard account code, when mapped."
          example: "3000"
          nullable: true
        suggestedPostingType:
          type: string
          description: "The posting type the mapped standard account suggests (Norwegian\
            \ standard chart only); null once postingType is set, while the account\
            \ is unmapped, or when the standard account suggests none (the kind of\
            \ item is unclear, or it depends on the company's choice of cost or fair\
            \ value). A hint only: nothing applies it."
          enum:
          - MONETARY
          - NON_MONETARY_HISTORICAL_COST
          - NON_MONETARY_FAIR_VALUE
          - EQUITY
          - PROFIT_AND_LOSS
          example: MONETARY
          nullable: true
          x-extensible-enum: true
        templateType:
          type: string
          description: "The reconciliation template the account follows (GENERAL_LEDGER_BALANCE,\
            \ BANK, SUB_LEDGER, ACCRUALS, ...)."
          enum:
          - GENERAL_LEDGER_BALANCE
          - GENERAL_LEDGER_BALANCE_PRO
          - GENERAL_LEDGER
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - ACCRUALS
          - VAT
          - PAYROLL
          - ASSETS
          example: GENERAL_LEDGER_BALANCE
          x-extensible-enum: true
        year:
          type: integer
          format: int32
          description: The accounting year this chart belongs to.
          example: 2026
      required:
      - accountId
      - accountNumber
      - documentationRequired
      - hasActivity
      - templateType
      - year
    LedgerResponse:
      type: object
      description: "One ledger of a company: the books of one accounting year from\
        \ one accounting system."
      properties:
        accountingSystem:
          type: string
          description: "The accounting system the ledger is bound to, by name (Api\
            \ for a ledger fed through this API); absent for a ledger bound to none."
          example: Api
          nullable: true
        apiManaged:
          type: boolean
          description: "Whether the ledger is bound to the Api accounting system:\
            \ the ledgers imports write."
        companyId:
          type: string
          format: uuid
          description: The company the ledger belongs to.
        createdAt:
          type: string
          format: date-time
          description: When the ledger was created.
        current:
          type: boolean
          description: "Whether this is the company's current ledger: the one reads\
            \ without a year use, and the first choice for its year. In the answer\
            \ to a create, whether the new ledger became current: a backfill year\
            \ does not."
        id:
          type: string
          format: uuid
          description: "The ledger's id: the ledgerId the trial balance and the sub-ledger\
            \ reconciliation report they were read from."
        year:
          type: integer
          format: int32
          description: The accounting year the ledger holds.
          example: 2025
      required:
      - apiManaged
      - companyId
      - createdAt
      - current
      - id
      - year
    Line:
      type: object
      description: A GL line in the series.
      properties:
        amount:
          type: number
          description: Amount.
          nullable: true
        lineId:
          type: string
          description: GL line id.
        period:
          type: integer
          format: int32
          description: Period.
          nullable: true
        role:
          type: string
          description: "BASIS or RECOGNITION, as the engine proposes."
          enum:
          - BASIS
          - RECOGNITION
          nullable: true
          x-extensible-enum: true
        text:
          type: string
          description: Line text.
          nullable: true
        transactionDate:
          type: string
          format: date
          description: Transaction date.
          nullable: true
        voucherNo:
          type: string
          description: "The voucher (bilag) number, as general-ledger lines' voucherNo."
          nullable: true
        year:
          type: integer
          format: int32
          description: Fiscal year.
          nullable: true
      required:
      - lineId
    LinkDocumentRequest:
      type: object
      description: "What to connect the document to: type, and the one target field\
        \ the type takes (with year, and optionally period, for an account)."
      properties:
        accountId:
          type: string
          format: uuid
          description: "ACCOUNT: The account's id; give accountNumber instead when\
            \ you have it."
          nullable: true
        accountNumber:
          type: string
          description: "ACCOUNT: The account's number in the chart of accounts, e.g.\
            \ \"1920\". Resolved in year's ledger, the current one without year."
          maxLength: 32
          nullable: true
        ledgerId:
          type: string
          format: uuid
          description: "ERP_LEDGER: the ledger's ledgerId."
          nullable: true
        lineId:
          type: string
          description: "GL_LINE: the line's lineId (list_general_ledger_lines)."
          maxLength: 200
          nullable: true
        openingBalanceId:
          type: string
          description: "OPENING_BALANCE: the opening balance's openingBalanceId."
          maxLength: 200
          nullable: true
        period:
          type: integer
          format: int32
          description: "Period of the accounting year in the cadence periodType names:\
            \ 1-12 for MONTHLY, 1-6 for BIMONTHLY, 1-4 for QUARTERLY, 1-3 for TERTIARY,\
            \ 1-2 for HALF_YEARLY, 1 for YEARLY. ACCOUNT only, with year: one period."
          nullable: true
        periodType:
          type: string
          description: "ACCOUNT only, with period: the account's own cadence (the\
            \ default)."
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          nullable: true
        runId:
          type: string
          format: uuid
          description: "RECON_RUN: the reconciliation run's runId."
          nullable: true
        type:
          type: string
          description: "ACCOUNT, GL_LINE, OPENING_BALANCE, VOUCHER, COMPANY, RECON_RUN\
            \ or ERP_LEDGER (any case). Optional when exactly one target field is\
            \ given; required for COMPANY."
          enum:
          - ACCOUNT
          - GL_LINE
          - OPENING_BALANCE
          - VOUCHER
          - COMPANY
          - RECON_RUN
          - ERP_LEDGER
          example: ACCOUNT
          nullable: true
        voucherKey:
          type: string
          description: "VOUCHER: the voucher's voucherKey."
          maxLength: 200
          nullable: true
        year:
          type: integer
          format: int32
          description: "ACCOUNT only: the accounting year the connection is for; without\
            \ period, the whole year. Leave it out for a general connection."
          nullable: true
    LinkIntercompanyAccountRequest:
      type: object
      properties:
        accountNumber:
          type: string
        dimensionKey:
          type: string
          maxLength: 200
          nullable: true
        expectedVersion:
          type: string
          description: The version the read returned (the groups' for a new link);
            refused with 409 if it changed since.
          maxLength: 64
          nullable: true
        lineId:
          type: string
          format: uuid
          description: The intercompany reconciliation line (a uuid; not a general-ledger
            lineId); required when the link has more than one line.
          nullable: true
        method:
          type: string
          enum:
          - ACCOUNT
          - SUBLEDGER
          - DIMENSION
        partyKey:
          type: string
          description: "The sub-ledger party of a SUBLEDGER link: its partyKey, as\
            \ listSubLedgers and listOpenItems return it."
          maxLength: 200
          nullable: true
      required:
      - accountNumber
      - method
    LinkedDependencyChange:
      type: object
      properties:
        accountNumber:
          type: string
          nullable: true
        after:
          type: number
          nullable: true
        before:
          type: number
          nullable: true
    MapAccountRequest:
      type: object
      properties:
        settingsRevision:
          type: integer
          format: int64
        standardAccountId:
          type: string
          format: uuid
      required:
      - settingsRevision
      - standardAccountId
    MapAccountsRequest:
      type: object
      properties:
        rows:
          type: array
          items:
            $ref: "#/components/schemas/AccountMappingRow"
          maxItems: 500
          minItems: 1
      required:
      - rows
    MasterDataResponse:
      type: object
      description: "A dimension value, identified by its company-wide key."
      properties:
        description:
          type: string
          nullable: true
        key:
          type: string
          description: "The stable, company-wide key."
          example: DEPT-10
        parentKey:
          type: string
          description: "The parent's key, for hierarchies."
          nullable: true
        type:
          type: string
          description: A free-form type label.
          example: department
          nullable: true
        value:
          type: string
          description: The display value.
          example: Sales
      required:
      - key
      - value
    MasterLine:
      type: object
      description: One dimension value or sub-ledger of the company.
      properties:
        description:
          type: string
          nullable: true
        key:
          type: string
          description: "The stable key (department code, customer number, ...)."
          example: DEPT-10
        parentKey:
          type: string
          description: "The parent's key, for hierarchies."
          nullable: true
        type:
          type: string
          description: A free-form type label.
          example: department
          nullable: true
        value:
          type: string
          description: The display value.
          example: Sales
      required:
      - key
      - value
    MatchRule:
      type: object
      properties:
        id:
          type: string
          maxLength: 64
        left:
          $ref: "#/components/schemas/MatchRuleSelector"
        op:
          type: string
          enum:
          - =
          - '>='
          - '!='
          - exclude
          x-extensible-enum: true
        right:
          $ref: "#/components/schemas/MatchRuleSelector"
        settings:
          $ref: "#/components/schemas/MatchRuleSettings"
      required:
      - id
      - left
      - op
    MatchRuleSelector:
      type: object
      properties:
        dimension:
          type: string
          nullable: true
        field:
          type: string
          nullable: true
        group:
          type: integer
          format: int32
          nullable: true
        regex:
          type: string
          maxLength: 256
          nullable: true
        subledger:
          type: string
          enum:
          - customer
          - supplier
          nullable: true
          x-extensible-enum: true
        value:
          type: string
          nullable: true
    MatchRuleSettings:
      type: object
      properties:
        tolerance:
          type: number
          minimum: 0
          nullable: true
        windowDays:
          type: integer
          format: int32
          maximum: 365
          minimum: 0
          nullable: true
    MatchRules:
      type: object
      description: A general-ledger account's match rules.
      nullable: true
      properties:
        rules:
          type: array
          description: The rules; an empty list removes them all.
          items:
            $ref: "#/components/schemas/MatchRule"
          maxItems: 50
        version:
          type: integer
          format: int32
          description: Rule-set version; 1 when absent.
          maximum: 1
          minimum: 1
          nullable: true
      required:
      - rules
    Mention:
      type: object
      description: An @-mention in the comment text.
      properties:
        displayName:
          type: string
          description: The person's name as written into the comment; null when none
            is on record. Never an e-mail address.
          nullable: true
        length:
          type: integer
          format: int32
          description: "Length of the mention, in UTF-16 code units."
        startOffset:
          type: integer
          format: int32
          description: "Start of the mention in the comment text, in UTF-16 code units."
        userId:
          type: string
          format: uuid
          description: The mentioned user.
      required:
      - length
      - startOffset
      - userId
    ModuleAutomationSettings:
      type: object
      properties:
        autoApprove:
          $ref: "#/components/schemas/InheritableBoolean"
        bankGlCorrectionsEnabled:
          $ref: "#/components/schemas/NullableInheritableBoolean"
        bankSecondPassEnabled:
          $ref: "#/components/schemas/NullableInheritableBoolean"
        bankSecondPassWindowDays:
          $ref: "#/components/schemas/NullableInheritableInteger"
        enabled:
          $ref: "#/components/schemas/InheritableBoolean"
        enabledOverride:
          type: boolean
          description: "The module's own stored on/off, null when it inherits. Unlike\
            \ enabled, not capped by the company switch: true here with the company's\
            \ automatic reconciliation off means the module is set on but does not\
            \ run until the company's is switched on."
          nullable: true
        groupWindowDays:
          $ref: "#/components/schemas/NullableInheritableInteger"
        matchWindowDays:
          $ref: "#/components/schemas/InheritableInteger"
        module:
          type: string
          enum:
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - GENERAL_LEDGER
          - BALANCE
          - ACCRUALS
          - ASSETS
          - VAT
          - PAYROLL
          - CURRENCY_K28
          - CURRENCY_K29
          x-extensible-enum: true
        secondPassEnabled:
          $ref: "#/components/schemas/InheritableBoolean"
        thresholds:
          $ref: "#/components/schemas/ModuleThresholds"
      required:
      - autoApprove
      - enabled
      - matchWindowDays
      - module
      - secondPassEnabled
    ModuleThresholds:
      type: object
      description: "CURRENCY_K28 and CURRENCY_K29 only, null on every other module:\
        \ the thresholds a currency control judges with, each the company's own or\
        \ the control's standard value (inherited)."
      nullable: true
      properties:
        flagAbsoluteNok:
          $ref: "#/components/schemas/InheritableDecimal"
        flagFloorNok:
          $ref: "#/components/schemas/InheritableDecimal"
        flagPercent:
          $ref: "#/components/schemas/InheritableDecimal"
        highFloorNok:
          $ref: "#/components/schemas/InheritableDecimal"
        highPercent:
          $ref: "#/components/schemas/InheritableDecimal"
      required:
      - flagAbsoluteNok
      - flagFloorNok
      - flagPercent
      - highFloorNok
      - highPercent
    MoveIntercompanyAccountRequest:
      type: object
      properties:
        expectedVersion:
          type: string
          description: The version the read returned (the groups' for a new link);
            refused with 409 if it changed since.
          maxLength: 64
          nullable: true
        lineId:
          type: string
          format: uuid
          description: Another intercompany reconciliation line of the same link (a
            uuid; not a general-ledger lineId).
      required:
      - lineId
    NullableInheritableBoolean:
      type: object
      description: "BANK only: a last round that pairs a ledger posting with its reversal\
        \ (same date, same amount, opposite sign) that no bank line took, saved as\
        \ a correction. Inherited, it is on. Null on every other module."
      nullable: true
      properties:
        inherited:
          type: boolean
        value:
          type: boolean
      required:
      - inherited
      - value
    NullableInheritableInteger:
      type: object
      description: "BANK only: the days apart the bank second pass's pairs and groups\
        \ may span. Inherited, it is 30. Null on every other module."
      nullable: true
      properties:
        inherited:
          type: boolean
        value:
          type: integer
          format: int32
      required:
      - inherited
      - value
    OpenItemEvidence:
      type: object
      description: "Open-item totals for a section in one currency, as of asOfDate."
      nullable: true
      properties:
        amountOpen:
          type: number
          description: Open amount as of asOfDate.
        currency:
          type: string
          example: NOK
          nullable: true
        maxDaysOverdue:
          type: integer
          format: int32
        openItemCount:
          type: integer
          format: int64
        overdueItemCount:
          type: integer
          format: int64
      required:
      - amountOpen
      - maxDaysOverdue
      - openItemCount
      - overdueItemCount
    OpenItemLine:
      type: object
      description: One customer or supplier document with its source-authoritative
        open amount (the import contract's subLedgerOpenItem). itemKey is unique within
        the request; unknown fields are refused.
      properties:
        accountCode:
          type: string
          description: The reconciliation account (customer or supplier ledger).
          example: "1500"
        amount:
          type: string
          description: "Signed amount in the company's base currency, as a decimal\
            \ string (a JSON number is also accepted)."
          example: "1250.0"
        amountOpen:
          type: string
          description: The open amount as the ERP states it (not recomputed from the
            matches).
          example: "250.0"
        currencyCode:
          type: string
          example: NOK
          nullable: true
        description:
          type: string
          nullable: true
        documentDate:
          type: string
          format: date
          example: 2025-03-14
        documentNo:
          type: string
          description: The document number accountants see.
          nullable: true
        dueDate:
          type: string
          format: date
          example: 2025-04-13
          nullable: true
        entryCategory:
          type: string
          description: "The ERP's kind of entry, e.g. invoice, credit_note, payment."
          example: invoice
        erpDocumentId:
          type: string
          description: "The ERP's own key for the source document (the contract's\
            \ documentId): text, not the id of a document in /v1/documents."
          example: inv-1001
          minLength: 1
        itemKey:
          type: string
          description: "Your stable key for the item, unique per company."
          example: inv-1001
          minLength: 1
        matches:
          type: array
          description: "The ERP's settlements of the item; matchKey is unique within\
            \ the item. In a snapshot mode, a match left out is retired."
          items:
            $ref: "#/components/schemas/OpenItemMatch"
        partyKey:
          type: string
          description: "The customer or supplier: its partyKey (the contract's subLedgerKey)."
          example: C-1001
          minLength: 1
        settledDate:
          type: string
          format: date
          nullable: true
        settlementStatus:
          type: string
          enum:
          - OPEN
          - PARTIAL
          - SETTLED
          - DELETED
          example: PARTIAL
        sourceDeleted:
          type: boolean
          description: true retires the item.
        subLedgerType:
          type: string
          description: Must match the request's subLedgerType (any case is accepted).
          enum:
          - CUSTOMER
          - SUPPLIER
        transactionAmount:
          type: string
          description: In the transaction currency.
          nullable: true
        transactionAmountOpen:
          type: string
          description: In the transaction currency.
          nullable: true
        transactionCurrencyCode:
          type: string
          example: EUR
          nullable: true
      required:
      - accountCode
      - amount
      - amountOpen
      - documentDate
      - entryCategory
      - erpDocumentId
      - itemKey
      - partyKey
      - settlementStatus
      - subLedgerType
    OpenItemMatch:
      type: object
      description: One ERP-side settlement or allocation of the item.
      properties:
        amount:
          type: string
          description: Decimal string (a JSON number is also accepted).
          example: "1000.0"
        counterpartItemKey:
          type: string
          description: The item on the other side of the settlement.
          nullable: true
        currencyCode:
          type: string
          nullable: true
        matchDate:
          type: string
          format: date
          example: 2025-04-01
        matchKey:
          type: string
          example: pay-77
          minLength: 1
      required:
      - amount
      - matchDate
      - matchKey
    OpenItemsImportRequest:
      type: object
      properties:
        fromDate:
          type: string
          format: date
          nullable: true
        items:
          type: array
          description: Open items in the import contract's shape.
          items:
            $ref: "#/components/schemas/OpenItemLine"
        mode:
          type: string
          description: "BASELINE | INCREMENTAL | FULL | FULL_REFRESH: snapshot modes\
            \ retire what is absent; INCREMENTAL only touches what is sent. Any case\
            \ is accepted."
          enum:
          - BASELINE
          - INCREMENTAL
          - FULL
          - FULL_REFRESH
          example: INCREMENTAL
        subLedgerType:
          type: string
          description: CUSTOMER or SUPPLIER (any case is accepted).
          enum:
          - CUSTOMER
          - SUPPLIER
          example: CUSTOMER
        toDate:
          type: string
          format: date
          nullable: true
      required:
      - items
      - mode
      - subLedgerType
    OpenItemsResponse:
      type: object
      description: "Sub-ledger open items as of a date, with aging totals over the\
        \ whole filtered set."
      properties:
        agingTotals:
          type: array
          description: "Open amount and counts per aging bucket and currency, over\
            \ every item the filters match (not just this page), in bucket order."
          items:
            $ref: "#/components/schemas/AgingBucketTotal"
        asOfDate:
          type: string
          format: date
          description: The date the open state and aging are computed for.
        companyId:
          type: string
          format: uuid
        data:
          type: array
          description: "This page of items, ordered by account, sub-ledger type, partyKey,\
            \ openItemId."
          items:
            $ref: "#/components/schemas/SubLedgerOpenItem"
        includeSettled:
          type: boolean
          description: Whether items settled by asOfDate are included.
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - agingTotals
      - asOfDate
      - companyId
      - data
      - includeSettled
      - pagination
    OpeningBalanceLine:
      type: object
      description: One opening-balance row of an account.
      properties:
        accountCode:
          type: string
          example: "1920"
        amount:
          type: string
          description: "Signed amount in the company's base currency, as a decimal\
            \ string (a JSON number is also accepted). At most four decimals."
          example: "125000.0"
        description:
          type: string
          nullable: true
        dimensionKeys:
          type: array
          items:
            type: string
            nullable: true
          nullable: true
        exchangeRate:
          type: number
          nullable: true
        id:
          type: string
          description: Your stable id for this row; re-sending the same id updates
            it.
          example: OB-1920
        partyKeys:
          type: array
          description: "The parties (customers, suppliers) the row is tagged with:\
            \ their partyKey."
          items:
            type: string
            description: "The parties (customers, suppliers) the row is tagged with:\
              \ their partyKey."
            nullable: true
          nullable: true
        transactionAmount:
          type: number
          nullable: true
        transactionCurrencyCode:
          type: string
          example: EUR
          nullable: true
      required:
      - accountCode
      - amount
      - id
    OpeningBalanceOpenItem:
      type: object
      description: The customer or supplier document behind an opening-balance item.
      nullable: true
      properties:
        documentDate:
          type: string
          format: date
          nullable: true
        documentNo:
          type: string
          nullable: true
        dueDate:
          type: string
          format: date
          nullable: true
        entryCategory:
          type: string
          nullable: true
        erpDocumentId:
          type: string
          description: "The ERP's own key for the source document: text, not the id\
            \ of a document in /v1/documents."
        openItemId:
          type: string
          format: uuid
          description: "Open-item id: the openItemId of list_open_items."
        partyKey:
          type: string
        partyType:
          type: string
          description: CUSTOMER or SUPPLIER.
          enum:
          - CUSTOMER
          - SUPPLIER
          nullable: true
          x-extensible-enum: true
      required:
      - erpDocumentId
      - openItemId
      - partyKey
    OpeningBalanceOverride:
      type: object
      description: "A person's opening balance, which replaces the calculated one."
      nullable: true
      properties:
        amount:
          type: number
          description: The opening balance the person set.
        createdAt:
          type: string
          format: date-time
          description: When it was set.
        createdBy:
          $ref: "#/components/schemas/PersonRef"
        currencyCode:
          type: string
          description: The currency it was set in.
          example: NOK
          nullable: true
        reason:
          type: string
          description: Why the person replaced the calculated figure.
          nullable: true
      required:
      - amount
      - createdAt
    OpeningBalancesImportRequest:
      type: object
      properties:
        lines:
          type: array
          items:
            $ref: "#/components/schemas/OpeningBalanceLine"
        year:
          type: integer
          format: int32
      required:
      - lines
      - year
    OrganizationResponse:
      type: object
      description: An organization within your reach.
      properties:
        id:
          type: string
          format: uuid
          description: "The organization's id: organizationId on the organization-scoped\
            \ operations."
        name:
          type: string
          description: The organization's name.
        parentId:
          type: string
          format: uuid
          description: "The parent organization, when it is within your reach too;\
            \ null for the top of your reach (whose parent, if any, you cannot reach)."
          nullable: true
      required:
      - id
      - name
    PageAccessPolicyResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AccessPolicyResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageAccountAccrualResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AccountAccrualResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageAccountActivityResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AccountActivityResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageAccountOpeningBalanceResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AccountOpeningBalanceResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageAccountStatusResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AccountStatusResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageAccrualSuggestionResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AccrualSuggestionResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageApprovalResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ApprovalResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageAuditEventResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AuditEventResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageBankAccount:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/BankAccount"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageBankGlLine:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/BankGlLine"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageBankTransaction:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/BankTransaction"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageBlockerResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/BlockerResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageCloseStatusResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CloseStatusResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageCommentResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CommentResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageCompanyAccessResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CompanyAccessResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageCompanyResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CompanyResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageCompanyUserResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CompanyUserResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageDeadlineResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/DeadlineResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageDocumentAssociation:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/DocumentAssociation"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageDocumentResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/DocumentResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageEffectiveAccessResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/EffectiveAccessResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageFlagResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/FlagResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageImportResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ImportResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageJobResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/JobResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageLedgerAccountResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/LedgerAccountResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageLedgerResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/LedgerResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageMasterDataResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/MasterDataResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageOrganizationResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/OrganizationResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PagePortfolioAccountStatusResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PortfolioAccountStatusResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PagePortfolioResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PortfolioResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageReconciliation:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Reconciliation"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageReconciliationAdjustmentResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ReconciliationAdjustmentResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageReconciliationRun:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ReconciliationRun"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageSettlementResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/SettlementResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageStatementBatch:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/StatementBatch"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageSubLedgerResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/SubLedgerResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageTaskResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/TaskResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageUserResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/UserResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageVatTermResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/VatTermResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageVoucherResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/VoucherResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageWebhookDeliveryResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/WebhookDeliveryResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageWebhookEndpointResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/WebhookEndpointResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    PageWorkQueueItemResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/WorkQueueItemResponse"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - data
      - pagination
    Pagination:
      type: object
      description: "One page today: the envelope every list uses (review m8)."
      properties:
        hasMore:
          type: boolean
          description: Whether another page follows.
        nextCursor:
          type: string
          description: Opaque cursor for the next page; null when this is the last
            page.
          nullable: true
      required:
      - hasMore
    Period:
      type: object
      description: One slice of an accrual schedule.
      properties:
        amount:
          type: number
          description: Amount accrued in this period.
        period:
          type: integer
          format: int32
          description: Period within the year.
        recognitionLineId:
          type: string
          description: "The GL line recognizing this slice, when recognized."
          nullable: true
        status:
          type: string
          description: PLANNED | RECOGNIZED.
          enum:
          - PLANNED
          - RECOGNIZED
          x-extensible-enum: true
        year:
          type: integer
          format: int32
          description: Fiscal year.
      required:
      - amount
      - period
      - status
      - year
    PeriodMovement:
      type: object
      description: The movement of one fiscal period.
      properties:
        amount:
          type: number
        period:
          type: integer
          format: int32
          description: Fiscal period 1–12.
      required:
      - amount
      - period
    PeriodSummary:
      type: object
      description: One period's state.
      properties:
        approvalFigures:
          $ref: "#/components/schemas/ApprovalFigures"
        approvalStatus:
          type: string
          description: "The firm's sign-off on the mapped GL account for this month:\
            \ APPROVED when an active attestation covers it, AWAITING_CONTROL when\
            \ that approval's policy still asks for a control by another person, REVOKED\
            \ when the latest one was withdrawn; null = never approved (or no GL mapping)."
          enum:
          - APPROVED
          - AWAITING_CONTROL
          - REVOKED
          nullable: true
          x-extensible-enum: true
        bankEntryCount:
          type: integer
          format: int32
          description: "This bank account's own transactions in those groups. A group\
            \ shared with another bank account on the same GL account counts each\
            \ account's lines under that account, so their summaries add up."
        glEntryCount:
          type: integer
          format: int32
          description: "GL entries of the groups stamped on this bank account. A GL\
            \ line cannot be split by bank account, so a shared group's GL entries\
            \ count once, under the account it is stamped on."
        groupCount:
          type: integer
          format: int32
          description: "Groups in the period that concern the bank account: created\
            \ on it, or holding one of its transactions. Each group counts once."
        hasStale:
          type: boolean
          description: Any group in the period has gone stale.
        period:
          type: integer
          format: int32
          description: "The month of the accounting year, 1-12, counted from its start\
            \ month."
      required:
      - approvalFigures
      - bankEntryCount
      - glEntryCount
      - groupCount
      - hasStale
      - period
    PersonRef:
      type: object
      description: "A person: user id and display name."
      nullable: true
      properties:
        displayName:
          type: string
          description: The person's name as the app shows it; absent when none is
            recorded.
          nullable: true
        userId:
          type: string
          format: uuid
          description: The user id.
      required:
      - userId
    PortfolioAccountStatusResponse:
      type: object
      description: Reconciliation counts of one company in a portfolio.
      properties:
        awaitingControlAccounts:
          type: integer
          format: int32
          description: "Accounts approved but still awaiting the control their approval\
            \ policy asks for; part of openAccounts, not of reconciledAccounts."
        companyId:
          type: string
          format: uuid
        companyName:
          type: string
        openAccounts:
          type: integer
          format: int32
          description: "Accounts not yet reconciled, those awaiting their control\
            \ included."
        reconciledAccounts:
          type: integer
          format: int32
        reconciledPercent:
          type: integer
          format: int32
          description: "0-100; 100 only when all are reconciled, 0 only when none\
            \ are."
        totalAccounts:
          type: integer
          format: int32
          description: Reconcilable balance-sheet accounts in the period; result accounts
            are not counted.
      required:
      - awaitingControlAccounts
      - companyId
      - companyName
      - openAccounts
      - reconciledAccounts
      - reconciledPercent
      - totalAccounts
    PortfolioResponse:
      type: object
      description: "A portfolio: a named group of an organization's companies."
      properties:
        companyIds:
          type: array
          description: "The member companies you can read, in name order, including\
            \ those you read only some accounts of (the portfolio work queue shows\
            \ those accounts; the portfolio status reads leave such a company out).\
            \ Members you cannot read are left out."
          items:
            type: string
            format: uuid
            description: "The member companies you can read, in name order, including\
              \ those you read only some accounts of (the portfolio work queue shows\
              \ those accounts; the portfolio status reads leave such a company out).\
              \ Members you cannot read are left out."
        id:
          type: string
          format: uuid
          description: "The portfolio's id: portfolioId on the portfolio reads."
        name:
          type: string
          description: The portfolio's name.
        organizationId:
          type: string
          format: uuid
          description: The organization the portfolio belongs to.
        status:
          type: string
          description: ACTIVE or ARCHIVED; deleted portfolios are not listed.
          enum:
          - ACTIVE
          - ARCHIVED
          example: ACTIVE
          x-extensible-enum: true
      required:
      - companyIds
      - id
      - name
      - organizationId
      - status
    Problem:
      type: object
      description: "RFC 9457 problem document — the shape of every error response.\
        \ The `error` property carries the stable machine code from the error catalog.\
        \ The extension members are present only where their description says so;\
        \ branch on `error`, then on `reason`, never on `detail`."
      properties:
        accountCode:
          type: string
          description: "400 on account settings: the account a rule names wrongly."
          nullable: true
        accountCodes:
          type: array
          description: "422 unknown_account_codes: the codes missing from the year's\
            \ chart (an import), or from every year's chart of the company (an access-policy\
            \ rule)."
          items:
            type: string
          nullable: true
        accountLinkId:
          type: string
          format: uuid
          description: "404 on an intercompany account: the account slice that was\
            \ not found."
          nullable: true
        accountNumber:
          type: string
          description: "400 on an intercompany account: the account code not found\
            \ in the company's ledgers."
          nullable: true
        accountPeriodType:
          type: string
          description: "409 account_period_type_mismatch (MCP): the account's own\
            \ reconciliation cadence."
          nullable: true
        accountTemplateId:
          type: string
          format: uuid
          description: "404 on choose_company_account_template: the template not found\
            \ in the company's organization."
          nullable: true
        accountingYear:
          type: integer
          description: "409 fiscal_year_overlap: the fiscal year that overlaps another."
          nullable: true
        active:
          type: boolean
          description: "With definitionId: whether that link is active."
          nullable: true
        actualPeriodType:
          type: string
          description: "With expectedPeriodType: the period type it has."
          nullable: true
        amountTolerance:
          type: number
          description: "With blockedReason: the tolerance the residual was checked\
            \ against."
          nullable: true
        bankAccountIds:
          type: array
          description: "409 bank_accounts_not_on_same_gl_account: the bank accounts\
            \ whose transactions cannot join this group."
          items:
            type: string
            format: uuid
          nullable: true
        bankTransactionIds:
          type: array
          description: "409 already_reconciled on create_reconciliation: the bank\
            \ transactions already in a group."
          items:
            type: string
            format: uuid
          nullable: true
        blockedReason:
          type: string
          description: "409 period_not_ready on approve_account_period and reapprove\
            \ (MCP): why the period is not ready, as get_account_reconciliation's\
            \ readiness says (OPEN_POSTS, RESIDUAL_ABOVE_TOLERANCE, NO_DATA)."
          nullable: true
        blockedYears:
          type: array
          description: "409 fetch_in_progress on trigger_erp_fetch (MCP): the accounting\
            \ years an ERP fetch in progress already covers."
          items:
            type: integer
          nullable: true
        commentType:
          type: string
          description: "400 on comments (MCP): the comment type that is not supported."
          nullable: true
        companyId:
          type: string
          format: uuid
          description: "400 on trigger_erp_fetch (MCP): the company with no ERP connected."
          nullable: true
        companyIds:
          type: array
          description: "409 restricted_rule_dropped on update_access_policy: the companies\
            \ whose template or account rules the update would drop unseen."
          items:
            type: string
            format: uuid
          nullable: true
        connectionId:
          type: string
          description: "409 association_exists on link_document: the document's connection\
            \ that is there already."
          nullable: true
        correlationId:
          type: string
          format: uuid
          description: "With blockedYears: the fetch in progress."
          nullable: true
        counterparty:
          type: string
          description: "With definitionId: that link's counterparty."
          nullable: true
        currencies:
          type: array
          description: "422 bank_match_currency_mismatch: the currencies the bank\
            \ transactions are in."
          items:
            type: string
          nullable: true
        currency:
          type: string
          description: "422 bank_match_currency_mismatch: the currency every line\
            \ must have an amount in."
          nullable: true
        currentRevision:
          type: integer
          format: int64
          description: "409 on an account settings write (update_account_settings,\
            \ clear_account_automation_overrides): the account's settingsRevision\
            \ now. Read the account again and re-apply your change."
          nullable: true
        currentVersion:
          type: string
          description: "409 on a company-level settings write (settings, automation,\
            \ contacts, the account template choice, intercompany links, routines):\
            \ the version the settings have now. Read them again and re-apply your\
            \ change; do not just retry with this value."
          nullable: true
        cycle:
          type: array
          description: "400 on account settings: the account_match rules that form\
            \ a cycle, in order."
          items:
            type: string
          nullable: true
        definitionId:
          type: string
          format: uuid
          description: "409 intercompany_* and 409 duplicate_resource on a counterparty\
            \ link: the link that already holds that part of the account, or that\
            \ counterparty."
          nullable: true
        detail:
          type: string
          description: Human-readable specifics
        dimensionKey:
          type: string
          description: "400 on an intercompany line: the dimension value not found\
            \ for the company."
          nullable: true
        email:
          type: string
          description: "409 duplicate_resource on a contact: the email another active\
            \ contact has."
          nullable: true
        erpAccountCode:
          type: string
          description: "With bankAccountIds: the GL account the group's bank account\
            \ feeds."
          nullable: true
        erpSystemId:
          type: string
          format: uuid
          description: "404 and 409 on trigger_erp_fetch (MCP): the ERP system at\
            \ fault."
          nullable: true
        error:
          type: string
          description: Stable machine code (see the error catalog)
        errors:
          type: array
          description: "Field-level problems for 400/422 answers, up to 100 items."
          items:
            type: object
            properties:
              allowedValues:
                type: array
                description: "The accepted values, when the field is an enumeration."
                items:
                  type: string
                nullable: true
              field:
                type: string
                description: The offending field.
              index:
                type: integer
                description: "0-based line index in the request, for list imports."
                nullable: true
              message:
                type: string
                description: What is wrong with it.
            required:
            - field
            - message
          nullable: true
        expectedPeriodType:
          type: string
          description: "400 on account settings: the period type a linked account\
            \ must have."
          nullable: true
        feature:
          type: string
          description: "403 feature_disabled on comments and flags (MCP): the module\
            \ that is off for the company."
          nullable: true
        flagTypeCode:
          type: string
          description: "400 on flag_item (MCP): the flag type that is unknown or inactive."
          nullable: true
        header:
          type: string
          description: "400 on Saga's internal surface: the request header that is\
            \ not accepted."
          nullable: true
        inUse:
          type: array
          description: "409 *_in_use on corrections: the objects (by your id or key)\
            \ that could not be deleted, each with what depends on it. Nothing was\
            \ deleted."
          items:
            type: object
            properties:
              dependencies:
                type: array
                items:
                  type: string
              id:
                type: string
            required:
            - dependencies
            - id
          nullable: true
        instance:
          type: string
        itemType:
          type: string
          description: "400 on flags (MCP): the item type that is not supported."
          nullable: true
        jobId:
          type: string
          format: uuid
          description: "409 job_in_flight: the job that blocks this one (when it is\
            \ yours)."
          nullable: true
        largestResidual:
          type: number
          description: "With blockedReason: the largest residual a settled match left."
          nullable: true
        ledgerId:
          type: string
          format: uuid
          description: "409 ledger_exists on create_api_ledger: the year's Api ledger."
          nullable: true
        length:
          type: integer
          description: "With startOffset: the mention's length."
          nullable: true
        limit:
          type: integer
          description: "413: the cap that was exceeded — lines per request, or body\
            \ bytes."
          nullable: true
        lineId:
          type: string
          description: "The one line at fault: 404 on an intercompany line, 409 line_already_settled\
            \ on a settlement."
          nullable: true
        lineIds:
          type: array
          description: "create_reconciliation (409 already_reconciled, opening_balance_settled;\
            \ 422): the GL lines or opening-balance rows at fault."
          items:
            type: string
          nullable: true
        lineType:
          type: string
          description: "400 on an intercompany line: the line type that is not known."
          nullable: true
        method:
          type: string
          description: "400 on an intercompany account: the link method that is not\
            \ known."
          nullable: true
        openPosts:
          type: integer
          description: "With blockedReason: the posts still open in the period."
          nullable: true
        ownerAccounts:
          type: array
          description: "400 on account settings: the two account_match rules that\
            \ would both approve accountCode."
          items:
            type: string
          nullable: true
        pairingKey:
          type: string
          description: "409 intercompany_pairing_key_taken: the pairing key another\
            \ line of the link uses."
          nullable: true
        parameter:
          type: string
          description: "400: the query, path or body parameter at fault."
          nullable: true
        partyKey:
          type: string
          description: "400 on an intercompany account: the sub-ledger party not found\
            \ for the company."
          nullable: true
        pattern:
          type: string
          description: "400 on account settings: the balanceRecon account pattern\
            \ that matches no account in the ledger."
          nullable: true
        pendingRequestId:
          type: string
          format: uuid
          description: "409 approval_request_pending (MCP): the request still pending\
            \ on the account period; read it with get_approval_request."
          nullable: true
        period:
          type: integer
          description: "400 on get_sub_ledger_reconciliation: the period outside 0–\
            12."
          nullable: true
        portfolioIds:
          type: array
          description: "409 portfolio_rule_would_widen on update_access_policy: the\
            \ portfolio rules the update would replace with an all-companies rule;\
            \ 409 restricted_rule_dropped: the portfolios whose template rules it\
            \ would drop unseen."
          items:
            type: string
            format: uuid
          nullable: true
        range:
          type: string
          description: "400 on account settings: the balanceRecon account range that\
            \ descends."
          nullable: true
        reason:
          type: string
          description: "A finer machine reason under the error code, e.g. company_not_api_managed,\
            \ job_in_flight, unknown_account_codes, lines_in_use, already_reconciled,\
            \ upload_not_completed, mode_not_available, company_read_only, confirmation_required,\
            \ feature_disabled, fiscal_year_overlap, intercompany_slice_owned. Branch\
            \ on it; never on `detail`."
          nullable: true
        requestId:
          type: string
          description: Echo in support requests — it indexes the logs
        requestedAt:
          type: string
          format: date-time
          description: "With blockedYears: when that fetch was requested."
          nullable: true
        requestedBy:
          type: string
          format: uuid
          description: "With blockedYears: who requested that fetch."
          nullable: true
        requiredScope:
          type: string
          description: "403 insufficient_scope: the scope the operation needs."
          nullable: true
        resetAt:
          type: string
          format: date-time
          description: "409 insufficient_credits on trigger_erp_fetch (MCP): when\
            \ the ERP's API credits reset."
          nullable: true
        retryAfterSeconds:
          type: integer
          description: "429, and 409 idempotency_in_flight: mirrors the Retry-After\
            \ header."
          nullable: true
        ruleId:
          type: string
          description: "400 on account settings: the match rule id that repeats."
          nullable: true
        sameLink:
          type: boolean
          description: "409 intercompany_*: true when that part of the account is\
            \ already on another line of this link."
          nullable: true
        scanner:
          type: string
          description: "503 at complete_document_upload: the virus scanner's reply."
          nullable: true
        signConvention:
          type: string
          description: "400 on an intercompany line: the sign convention that is not\
            \ known."
          nullable: true
        standardAccountId:
          type: string
          format: uuid
          description: "400 on map_account and map_accounts: the standard account\
            \ that is not one of the company's country."
          nullable: true
        startOffset:
          type: integer
          description: "400 on add_comment (MCP): where the mention starts in the\
            \ text."
          nullable: true
        state:
          type: string
          description: "500 on trigger_erp_fetch (MCP): the connector state that is\
            \ not known."
          nullable: true
        status:
          type: integer
        supported:
          type: array
          description: "415: the media types the operation accepts."
          items:
            type: string
          nullable: true
        termNo:
          type: integer
          description: "With year: the term no setup resolves."
          nullable: true
        termPeriodType:
          type: string
          description: "With accountPeriodType: the cadence the request or the frequency\
            \ setup names."
          nullable: true
        title:
          type: string
        type:
          type: string
          description: URI ending in the error's catalog slug
        userId:
          type: string
          format: uuid
          description: "400 on add_comment (MCP): the mentioned person who cannot\
            \ read the company."
          nullable: true
        warnings:
          type: array
          description: "422 confirmation_required: the account-template warnings still\
            \ to be confirmed (TEMPLATE_CHANGED, DOCUMENTATION_REQUIREMENT_REMOVED,\
            \ AUTO_APPROVE_ENABLED)."
          items:
            type: string
          nullable: true
        year:
          type: integer
          description: "409 frequency_setup_required (MCP): the year of the term no\
            \ setup resolves."
          nullable: true
      required:
      - error
      - requestId
      - status
      - title
      - type
    Readiness:
      type: object
      description: "Whether the period could be approved now, and why not."
      properties:
        amountChanged:
          type: boolean
          description: The standing approval recorded a different amount than the
            period now holds.
        amountTolerance:
          type: number
          nullable: true
        approvedAmount:
          type: number
          description: "The standing approval's amount, when there is one."
          nullable: true
        blockedReason:
          type: string
          description: "Why not: OPEN_POSTS, RESIDUAL_ABOVE_TOLERANCE, or NO_DATA\
            \ (nothing fetched for the period); null when ready."
          enum:
          - OPEN_POSTS
          - RESIDUAL_ABOVE_TOLERANCE
          - NO_DATA
          nullable: true
          x-extensible-enum: true
        currentAmount:
          type: number
          description: What an approval now would record.
          nullable: true
        largestResidual:
          type: number
          nullable: true
        openPosts:
          type: integer
          format: int64
        readyToApprove:
          type: boolean
        totalPosts:
          type: integer
          format: int64
      required:
      - amountChanged
      - openPosts
      - readyToApprove
      - totalPosts
    Reconciliation:
      type: object
      description: "A reconciliation group: bank transactions matched against GL lines\
        \ for one period."
      properties:
        auto:
          type: boolean
          description: True when the automatcher made the group; false when a person
            (or an API client) did.
        bankAccountId:
          type: string
          format: uuid
          description: "The bank account the group was created on. Bank accounts that\
            \ share a GL account can be matched in one group, so its bank entries\
            \ may also belong to another of them."
        bankAmountTotal:
          type: number
          description: Snapshot of the bank side at match time. The group balances
            when glAmountTotal minus bankAmountTotal is zero (both sides carry a movement
            with the same sign).
        bankEntries:
          type: array
          items:
            $ref: "#/components/schemas/BankEntry"
        createdAt:
          type: string
          format: date-time
        currencyCode:
          type: string
          description: "The currency the group is matched in, which its totals and\
            \ GL amounts are in: a foreign-currency bank account's own currency (its\
            \ GL lines then count with their transaction amount), else the company's\
            \ base currency for the year."
          example: NOK
        glAmountTotal:
          type: number
          description: Snapshot of the GL side at match time.
        glEntries:
          type: array
          items:
            $ref: "#/components/schemas/GlEntry"
        id:
          type: string
          format: uuid
        kind:
          type: string
          description: "MATCH: ledger posts against bank transactions (or bank transactions\
            \ only, such as a transfer between two bank accounts on the same GL account).\
            \ CORRECTION: ledger posts only, with no bank transaction, such as a posting\
            \ and its reversal."
          enum:
          - MATCH
          - CORRECTION
          example: MATCH
          x-extensible-enum: true
        note:
          type: string
          nullable: true
        period:
          type: integer
          format: int32
          description: Fiscal period 1-12.
        stale:
          type: boolean
          description: "True when the group needs review: a matched bank transaction\
            \ or GL line changed or vanished after matching, a matched opening-balance\
            \ row changed amount, lost its amount in the group's currency or was split,\
            \ or either side's entries no longer sum to its snapshot total."
        year:
          type: integer
          format: int32
      required:
      - auto
      - bankAccountId
      - bankAmountTotal
      - bankEntries
      - createdAt
      - currencyCode
      - glAmountTotal
      - glEntries
      - id
      - kind
      - period
      - stale
      - year
    ReconciliationAdjustmentResponse:
      type: object
      description: A manual explanation of part of an account-period's reconciliation
        difference.
      properties:
        amount:
          type: number
        createdAt:
          type: string
          format: date-time
        createdBy:
          $ref: "#/components/schemas/PersonRef"
        description:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
          description: Adjustment id.
      required:
      - amount
      - createdAt
      - id
    ReconciliationRun:
      type: object
      description: An automatic reconciliation run of the company.
      properties:
        accountCount:
          type: integer
          format: int32
          description: "How many accounts the run reconciles, once started."
          nullable: true
        accountId:
          type: string
          format: uuid
          description: "The account, for a run of one account (erp.account id), when\
            \ known."
          nullable: true
        accountNumber:
          type: string
          description: "The account's number, for a run of one account."
          nullable: true
        accounts:
          type: array
          description: "Per account (and pass), at most 500: status and error. Only\
            \ on get_reconciliation_run; null in a list."
          items:
            $ref: "#/components/schemas/RunAccount"
          nullable: true
        error:
          type: string
          description: The failure text the run or core recorded.
          nullable: true
        finishedAt:
          type: string
          format: date-time
          description: When it finished; null until then.
          nullable: true
        reason:
          type: string
          description: "A code for a FAILED or SKIPPED run when one is known: not_delivered,\
            \ not_started, bank_currency_unsupported, run_in_progress, automation_not_enabled,\
            \ account_not_found, account_year_mismatch, company_read_only (the organization\
            \ was terminated before the run started), account_skipped, cancelled."
          nullable: true
        requestedAt:
          type: string
          format: date-time
          description: "When it was ordered (scheduled runs: when CAR created it)."
        requestedThroughApi:
          type: boolean
          description: Whether it was ordered with request_reconciliation_run.
        runId:
          type: string
          format: uuid
        startedAt:
          type: string
          format: date-time
          description: "When it started: when its run row was written."
          nullable: true
        status:
          type: string
          description: "PENDING: not started yet. PROCESSING: running. SUCCEEDED,\
            \ FAILED, SKIPPED: finished; SKIPPED means the run did nothing (reason\
            \ says why)."
          enum:
          - PENDING
          - PROCESSING
          - SUCCEEDED
          - FAILED
          - SKIPPED
          x-extensible-enum: true
        trigger:
          type: string
          description: "What started it: SCHEDULED (CAR's schedule), MANUAL (a person\
            \ in the app, or the API), BALANCE_ROLL_FORWARD (after an approval), OTHER."
          enum:
          - SCHEDULED
          - MANUAL
          - BALANCE_ROLL_FORWARD
          - OTHER
          x-extensible-enum: true
        year:
          type: integer
          format: int32
          description: "The accounting year it reconciles, when known."
          nullable: true
      required:
      - requestedAt
      - requestedThroughApi
      - runId
      - status
      - trigger
    ReconciliationSummary:
      type: object
      description: The reconciliation picture for one bank account across a year.
      properties:
        bankAccountId:
          type: string
          format: uuid
        periods:
          type: array
          description: "The year's twelve months, in fiscal order. When the request\
            \ passes accountPeriod, only the month that account period ends in."
          items:
            $ref: "#/components/schemas/PeriodSummary"
        year:
          type: integer
          format: int32
      required:
      - bankAccountId
      - periods
      - year
    RenameRequest:
      type: object
      properties:
        displayName:
          type: string
          maxLength: 255
      required:
      - displayName
    RequestRunsRequest:
      type: object
      properties:
        accounts:
          type: array
          items:
            $ref: "#/components/schemas/RunAccountRef"
          maxItems: 50
          minItems: 1
        year:
          type: integer
          format: int32
          description: The accounting year (from 2000 to next year).
          minimum: 2000
      required:
      - accounts
      - year
    RequestedRun:
      type: object
      description: What happened to one requested account.
      properties:
        accountId:
          type: string
          format: uuid
          description: The account (erp.account id).
        accountNumber:
          type: string
          description: The account's number.
        reason:
          type: string
          description: "Why nothing was started: automation_not_enabled, or rate_limited\
            \ (a run was ordered for the account too recently). Null for ACCEPTED."
          nullable: true
        retryAfterSeconds:
          type: integer
          format: int64
          description: "For rate_limited: seconds until the account can be ordered\
            \ again."
          nullable: true
        runId:
          type: string
          format: uuid
          description: "The run, for ACCEPTED: read it with get_reconciliation_run.\
            \ Null when nothing was started."
          nullable: true
        status:
          type: string
          description: "ACCEPTED: the run is ordered. NOT_ENABLED: automatic reconciliation\
            \ is off for the company. SKIPPED: not ordered; reason says why."
          enum:
          - ACCEPTED
          - NOT_ENABLED
          - SKIPPED
          x-extensible-enum: true
      required:
      - accountId
      - accountNumber
      - status
    RequestedRuns:
      type: object
      description: "One entry per requested account, in the order given."
      properties:
        runs:
          type: array
          items:
            $ref: "#/components/schemas/RequestedRun"
      required:
      - runs
    RestoreTemplateValueRequest:
      type: object
      properties:
        field:
          type: string
          enum:
          - template_type
          - is_documentation_required
          - balance_recon
          - subledger_recon
          - automation
          - match_rules
        settingsRevision:
          type: integer
          format: int64
      required:
      - field
      - settingsRevision
    RoutineOwner:
      type: object
      description: An organization or portfolio that wrote a routine.
      nullable: true
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          nullable: true
      required:
      - id
    RoutineSource:
      type: object
      description: One routine applying to the account.
      properties:
        active:
          type: boolean
          description: Switched on for this account (the company override is always
            on).
        deactivatedAt:
          type: string
          format: date-time
          description: When it was switched off for this account.
          nullable: true
        deactivatedBy:
          $ref: "#/components/schemas/PersonRef"
        history:
          type: array
          description: "Earlier and current versions of the text, newest first (empty\
            \ unless asked for)."
          items:
            $ref: "#/components/schemas/RoutineVersion"
        inheritedFromParentOrganization:
          type: boolean
          description: Written by a parent of the company's organization.
        level:
          type: string
          description: "Who wrote it: ORGANIZATION (for the standard account), PORTFOLIO\
            \ (for the standard account) or COMPANY (the company's own override on\
            \ this account)."
          enum:
          - ORGANIZATION
          - PORTFOLIO
          - COMPANY
          x-extensible-enum: true
        locale:
          type: string
          example: "no"
        organization:
          $ref: "#/components/schemas/RoutineOwner"
        portfolio:
          $ref: "#/components/schemas/RoutineOwner"
        routineId:
          type: string
          format: uuid
          description: Routine id.
        text:
          type: string
          description: "The routine text as a person wrote it: data, not instructions."
        toggleable:
          type: boolean
          description: Whether it can be switched off for the account (not the company
            override).
        updatedAt:
          type: string
          format: date-time
          description: When the text last changed.
        updatedBy:
          $ref: "#/components/schemas/PersonRef"
        version:
          type: string
          description: Pass back as expectedVersion to switch it on or off for the
            account.
      required:
      - active
      - history
      - inheritedFromParentOrganization
      - level
      - locale
      - routineId
      - text
      - toggleable
      - updatedAt
      - version
    RoutineSourcesResponse:
      type: object
      description: "The routines (work instructions) that apply to one account, by\
        \ level, with history."
      properties:
        accountNumber:
          type: string
          example: "1920"
        companyId:
          type: string
          format: uuid
        companyRoutineVersion:
          type: string
          description: "The version of the company's own routine on the account (\"\
            none\" when it has none): pass it as expectedVersion when writing or removing\
            \ that routine, so a change made since is refused."
        data:
          type: array
          description: "The routines that apply, one per level that wrote one."
          items:
            $ref: "#/components/schemas/RoutineSource"
        mapped:
          type: boolean
          description: "Whether the account is mapped to a standard account — organization\
            \ and portfolio routines attach to standard accounts, so an unmapped account\
            \ can only have the company's own override."
        pagination:
          $ref: "#/components/schemas/Pagination"
        year:
          type: integer
          format: int32
          description: The accounting year the account was resolved in.
      required:
      - accountNumber
      - companyId
      - companyRoutineVersion
      - data
      - mapped
      - pagination
      - year
    RoutineVersion:
      type: object
      description: One captured version of a routine's text.
      properties:
        changeType:
          type: string
          description: "INSERT, UPDATE or DELETE."
          enum:
          - INSERT
          - UPDATE
          - DELETE
          x-extensible-enum: true
        changedBy:
          $ref: "#/components/schemas/PersonRef"
        text:
          type: string
          nullable: true
        validFrom:
          type: string
          format: date-time
        validTo:
          type: string
          format: date-time
          description: Absent for the current version.
          nullable: true
      required:
      - changeType
      - validFrom
    Rule:
      type: object
      description: "One rule: a role on one company, on a portfolio's companies, or\
        \ on every company, over all their accounts, some templates' accounts or some\
        \ account codes."
      properties:
        accountCodes:
          type: array
          description: "The ERP account codes an ACCOUNTS rule covers, in every accounting\
            \ year of the company, sorted; empty otherwise."
          items:
            type: string
            example: "1920"
        companyId:
          type: string
          format: uuid
          description: The company for a COMPANY rule; null otherwise.
          nullable: true
        portfolioId:
          type: string
          format: uuid
          description: The portfolio for a PORTFOLIO rule; null otherwise.
          nullable: true
        resourceScope:
          type: string
          description: "What the role is granted over: ALL every account of the target,\
            \ TEMPLATES the accounts of templateTypes, ACCOUNTS the accountCodes (a\
            \ COMPANY rule only)."
          enum:
          - ALL
          - TEMPLATES
          - ACCOUNTS
          example: ALL
          x-extensible-enum: true
        role:
          type: string
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: ACCOUNTANT
          x-extensible-enum: true
        scopeType:
          type: string
          description: What the rule covers. PORTFOLIO rules expand to the portfolio's
            current members.
          enum:
          - COMPANY
          - ORGANIZATION
          - PORTFOLIO
          example: COMPANY
          x-extensible-enum: true
        templateTypes:
          type: array
          description: "The templates whose accounts a TEMPLATES rule covers, in core's\
            \ template order; empty otherwise."
          items:
            type: string
            enum:
            - VAT
            - PAYROLL
            - ASSETS
            - BANK
            - SIMPLE_BANK
            - ACCRUALS
            - GENERAL_LEDGER_BALANCE
            - GENERAL_LEDGER_BALANCE_PRO
            - GENERAL_LEDGER
            - SUB_LEDGER
            x-extensible-enum: true
      required:
      - accountCodes
      - resourceScope
      - role
      - scopeType
      - templateTypes
    RuleInput:
      type: object
      description: "One rule of a policy document: a role on a target (a company,\
        \ a portfolio's companies or every company), over all its accounts, the accounts\
        \ of some templates, or some account codes."
      properties:
        accountCodes:
          type: array
          description: "The ERP account codes the role covers, in every accounting\
            \ year of the company: required with resourceScope ACCOUNTS, absent or\
            \ empty otherwise. Each must be a code one of the company's ledgers has\
            \ carried."
          items:
            type: string
            example: "1920"
            maxLength: 64
            minLength: 1
          maxItems: 1000
          nullable: true
        companyId:
          type: string
          format: uuid
          description: "The company; required for, and only valid with, scopeType\
            \ COMPANY."
          nullable: true
        portfolioId:
          type: string
          format: uuid
          description: "The portfolio (of the policy's organization); required for,\
            \ and only valid with, scopeType PORTFOLIO. The grant follows the portfolio's\
            \ members."
          nullable: true
        resourceScope:
          type: string
          description: "What the role is granted over. ALL (default) covers every\
            \ account, TEMPLATES the accounts of templateTypes, ACCOUNTS the accountCodes.\
            \ ACCOUNTS needs scopeType COMPANY: account codes belong to one company.\
            \ A policy holds one rule per target and resourceScope, so ALL and ACCOUNTS\
            \ on the same company are two rules."
          enum:
          - ALL
          - TEMPLATES
          - ACCOUNTS
          nullable: true
        role:
          type: string
          description: The role the rule grants.
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: ACCOUNTANT
        scopeType:
          type: string
          description: "What the rule points at. Omit to infer it from the target\
            \ given: COMPANY when companyId is set, PORTFOLIO when portfolioId is\
            \ set, otherwise ORGANIZATION (every company in the organization). When\
            \ the policy holds a PORTFOLIO rule that this replace would drop, an all-companies\
            \ rule must say ORGANIZATION explicitly."
          enum:
          - ORGANIZATION
          - COMPANY
          - PORTFOLIO
          nullable: true
        templateTypes:
          type: array
          description: "The templates whose accounts the role covers: required with\
            \ resourceScope TEMPLATES, absent or empty otherwise."
          items:
            type: string
            enum:
            - VAT
            - PAYROLL
            - ASSETS
            - BANK
            - SIMPLE_BANK
            - ACCRUALS
            - GENERAL_LEDGER_BALANCE
            - GENERAL_LEDGER_BALANCE_PRO
            - GENERAL_LEDGER
            - SUB_LEDGER
          maxItems: 20
          nullable: true
      required:
      - role
    RunAccount:
      type: object
      description: One account of a run.
      nullable: true
      properties:
        accountId:
          type: string
          format: uuid
          description: "The account (erp.account id), when it still exists."
          nullable: true
        accountNumber:
          type: string
        error:
          type: string
          description: The failure text for this account.
          nullable: true
        pass:
          type: integer
          format: int32
          description: "1 for the first matching pass, 2 for the optional wide second\
            \ pass; null before the account's task exists."
          nullable: true
        status:
          type: string
          enum:
          - PENDING
          - PROCESSING
          - SUCCEEDED
          - FAILED
          - SKIPPED
          x-extensible-enum: true
      required:
      - accountNumber
      - status
    RunAccountRef:
      type: object
      properties:
        accountId:
          type: string
          format: uuid
          description: "The account (erp.account id, list_account_status data[].accountId):\
            \ preferred, unambiguous."
          nullable: true
        accountNumber:
          type: string
          description: "The account number, looked up in the year's ledger."
          maxLength: 32
          nullable: true
          pattern: "^[A-Za-z0-9._-]{1,32}$"
    SetAccountRoutineRequest:
      type: object
      properties:
        expectedVersion:
          type: string
          description: companyRoutineVersion from the routines read; refused with
            409 if the company's routine changed since.
          maxLength: 64
          nullable: true
        text:
          type: string
          description: The routine as plain text; blank lines separate paragraphs.
          maxLength: 20000
      required:
      - text
    SetRoutineSourceActiveRequest:
      type: object
      properties:
        active:
          type: boolean
        expectedVersion:
          type: string
          description: The routine's version from the routines read; refused with
            409 if it changed since.
          maxLength: 64
          nullable: true
      required:
      - active
    SettlementLine:
      type: object
      description: One general-ledger line (or opening balance) in a settlement.
      properties:
        accountName:
          type: string
          nullable: true
        accountNumber:
          type: string
          description: The line's account.
          nullable: true
        amount:
          type: number
          description: The amount the line contributes.
        description:
          type: string
          nullable: true
        lineId:
          type: string
          description: "The GL line's lineId, or an opening balance's openingBalanceId\
            \ (list_opening_balances)."
        openingBalance:
          type: boolean
          description: "The line is an opening balance, not a GL posting."
        period:
          type: integer
          format: int32
          description: The line's period; 0 for an opening balance.
          nullable: true
        postedDate:
          type: string
          format: date
          nullable: true
        side:
          type: string
          description: "DEBIT or CREDIT (stored as the writer sent it, in any case)."
          enum:
          - DEBIT
          - CREDIT
          x-extensible-enum: true
        transactionDate:
          type: string
          format: date
          description: Document date (the fiscal-year start for an opening balance).
          nullable: true
        voucherNo:
          type: string
          description: Voucher (bilag) number; OB-1 for an opening balance.
          nullable: true
        year:
          type: integer
          format: int32
          nullable: true
      required:
      - amount
      - lineId
      - openingBalance
      - side
    SettlementResponse:
      type: object
      description: "A settlement (utligning): general-ledger lines offset against\
        \ each other on an account."
      properties:
        accountNumber:
          type: string
          description: The account the settlement was made on.
          example: "1500"
        amount:
          type: number
          description: The settled amount (one side's total).
        automatch:
          $ref: "#/components/schemas/Automatch"
        createdAt:
          type: string
          format: date-time
          description: When the settlement was made.
        createdBy:
          $ref: "#/components/schemas/PersonRef"
        difference:
          type: number
          description: Debits minus credits across the legs; 0 when balanced.
        id:
          type: string
          format: uuid
          description: Settlement id.
        lines:
          type: array
          description: "The lines in the settlement, in the order they were added."
          items:
            $ref: "#/components/schemas/SettlementLine"
        partial:
          type: boolean
          description: True when a remainder of 0.05 or more is left.
        period:
          type: integer
          format: int32
          description: "The period the settlement was made in, within the year."
        periodType:
          type: string
          description: MONTHLY | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY |
            YEARLY.
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          example: MONTHLY
          x-extensible-enum: true
        status:
          type: string
          description: "SETTLED (difference below 0.05, rounding) or PARTIAL (a remainder\
            \ is left)."
          enum:
          - SETTLED
          - PARTIAL
          x-extensible-enum: true
        type:
          type: string
          description: AUTO (the automatcher) or MANUAL.
          enum:
          - AUTO
          - MANUAL
          x-extensible-enum: true
        year:
          type: integer
          format: int32
          description: "The period the settlement was made in: year."
      required:
      - accountNumber
      - amount
      - createdAt
      - difference
      - id
      - lines
      - partial
      - period
      - periodType
      - status
      - type
      - year
    Stage:
      type: object
      properties:
        awaitingControlCount:
          type: integer
          format: int32
          description: Accounts in the stage approved but still awaiting the control
            their approval policy asks for; not in reconciledCount. Null when the
            stage counts no accounts (na and engine stages).
          nullable: true
        key:
          type: string
          description: "BANK, BALANCE, HOVEDBOK, ACCRUALS, PAYROLL, ASSETS, OTHER,\
            \ AR, AP or VAT."
          enum:
          - BANK
          - BALANCE
          - HOVEDBOK
          - ACCRUALS
          - PAYROLL
          - ASSETS
          - OTHER
          - AR
          - AP
          - VAT
          x-extensible-enum: true
        reason:
          type: string
          description: "Why a stage is NA: NO_RECONCILABLE_ACCOUNTS, NO_SUB_LEDGER,\
            \ or VAT_STATUS_NOT_AVAILABLE (VAT is not covered by this API)."
          enum:
          - NO_RECONCILABLE_ACCOUNTS
          - NO_SUB_LEDGER
          - VAT_STATUS_NOT_AVAILABLE
          nullable: true
          x-extensible-enum: true
        reconciledCount:
          type: integer
          format: int32
          nullable: true
        reconciledPercent:
          type: integer
          format: int32
          nullable: true
        status:
          type: string
          description: "DONE, ACTIVE (started), WARN (a drifted approval, or a sub-ledger\
            \ break), TODO (not started) or NA (does not apply)."
          enum:
          - DONE
          - ACTIVE
          - WARN
          - TODO
          - NA
          x-extensible-enum: true
        templateTypes:
          type: array
          description: "The account templates the stage rolls up; empty for the AR,\
            \ AP and VAT stages."
          enum:
          - GENERAL_LEDGER_BALANCE
          - GENERAL_LEDGER_BALANCE_PRO
          - GENERAL_LEDGER
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - ACCRUALS
          - VAT
          - PAYROLL
          - ASSETS
          items:
            type: string
            description: "The account templates the stage rolls up; empty for the\
              \ AR, AP and VAT stages."
            enum:
            - GENERAL_LEDGER_BALANCE
            - GENERAL_LEDGER_BALANCE_PRO
            - GENERAL_LEDGER
            - BANK
            - SIMPLE_BANK
            - SUB_LEDGER
            - ACCRUALS
            - VAT
            - PAYROLL
            - ASSETS
            x-extensible-enum: true
          x-extensible-enum: true
        totalCount:
          type: integer
          format: int32
          nullable: true
      required:
      - key
      - status
      - templateTypes
    StandardAccount:
      type: object
      description: A standard account a company account can be mapped to.
      nullable: true
      properties:
        description:
          type: string
          nullable: true
        documentationRequired:
          type: boolean
          description: Whether accounts mapped to it start requiring documentation.
        id:
          type: string
          format: uuid
        number:
          type: string
          example: "1920"
        templateType:
          type: string
          description: The reconciliation template accounts mapped to it start with.
          enum:
          - GENERAL_LEDGER_BALANCE
          - GENERAL_LEDGER_BALANCE_PRO
          - GENERAL_LEDGER
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - ACCRUALS
          - VAT
          - PAYROLL
          - ASSETS
          nullable: true
          x-extensible-enum: true
      required:
      - documentationRequired
      - id
      - number
    StandardAccounts:
      type: object
      properties:
        companyId:
          type: string
          format: uuid
        countryCode:
          type: string
          description: "The company's country: the standard accounts it can map to."
        data:
          type: array
          items:
            $ref: "#/components/schemas/StandardAccount"
        pagination:
          $ref: "#/components/schemas/Pagination"
      required:
      - companyId
      - countryCode
      - data
      - pagination
    StatementBatch:
      type: object
      description: "One confirmed upload of bank lines to a manual bank account: the\
        \ file, the dates its lines cover, who uploaded it and, once reverted, who\
        \ reverted it, why, and which reconciliation groups that dissolved."
      properties:
        activeLineCount:
          type: integer
          format: int64
          description: "How many of them are still on the account: fewer than lineCount\
            \ once single lines are deleted, none once the upload is reverted."
        bankAccountId:
          type: string
          format: uuid
        createdAt:
          type: string
          format: date-time
          description: When it was confirmed.
        createdBy:
          $ref: "#/components/schemas/PersonRef"
        dateFrom:
          type: string
          format: date
          description: The earliest booking date among the upload's lines.
        dateTo:
          type: string
          format: date
          description: The latest booking date among the upload's lines.
        fileName:
          type: string
          description: The uploaded file's name.
          nullable: true
        id:
          type: string
          format: uuid
          description: The upload's id.
        lineCount:
          type: integer
          format: int32
          description: How many lines the upload brought.
        reopenedReconciliationGroupIds:
          type: array
          description: The reconciliation groups the revert dissolved because they
            held its lines (their former reconciliationGroupId). Empty while committed.
          items:
            type: string
            format: uuid
            description: The reconciliation groups the revert dissolved because they
              held its lines (their former reconciliationGroupId). Empty while committed.
        revertReason:
          type: string
          description: Why it was reverted; null while committed.
          nullable: true
        revertedAt:
          type: string
          format: date-time
          description: When it was reverted; null while committed.
          nullable: true
        revertedBy:
          $ref: "#/components/schemas/PersonRef"
        status:
          type: string
          description: "COMMITTED: its lines are on the account. REVERTED: a person\
            \ took the upload back and its lines were deleted."
          enum:
          - COMMITTED
          - REVERTED
          example: COMMITTED
          x-extensible-enum: true
        sumIn:
          type: number
          description: The sum of the upload's incoming amounts.
        sumOut:
          type: number
          description: "The sum of the upload's outgoing amounts, as a positive number."
      required:
      - activeLineCount
      - bankAccountId
      - createdAt
      - dateFrom
      - dateTo
      - id
      - lineCount
      - reopenedReconciliationGroupIds
      - status
      - sumIn
      - sumOut
    SubLedgerLine:
      type: object
      description: "One sub-ledger party of the company (a customer, a supplier, ...)."
      properties:
        description:
          type: string
          nullable: true
        parentPartyKey:
          type: string
          description: "The parent party's partyKey, for hierarchies."
          nullable: true
        partyKey:
          type: string
          description: "The party's stable key (customer number, supplier number,\
            \ ...): the partyKey list_sub_ledgers and open items return."
          example: C-1001
        type:
          type: string
          description: A free-form type label.
          example: customer
          nullable: true
        value:
          type: string
          description: The display value.
          example: Kunde AS
      required:
      - partyKey
      - value
    SubLedgerOpenItem:
      type: object
      description: "One customer or supplier open item (invoice, credit note, payment,\
        \ ...)."
      properties:
        accountNumber:
          type: string
          description: The control account the item sits on.
          example: "1500"
        agingBucket:
          type: string
          enum:
          - NO_DUE_DATE
          - NOT_DUE
          - 0-30
          - 31-60
          - 61-90
          - 91+
          x-extensible-enum: true
        amount:
          type: number
          description: "Original amount, signed."
        amountOpen:
          type: number
          description: "Open amount today, signed."
        amountOpenAsOf:
          type: number
          description: "Open amount as of asOfDate, signed."
        commentCount:
          type: integer
          format: int32
          description: Active comments on the item.
        currency:
          type: string
          description: Currency of the amounts.
          example: NOK
          nullable: true
        daysOverdue:
          type: integer
          format: int32
          description: Days past due as of asOfDate (negative = not yet due).
          nullable: true
        description:
          type: string
          nullable: true
        documentDate:
          type: string
          format: date
          nullable: true
        documentNo:
          type: string
          description: The source document's number.
          nullable: true
        dueDate:
          type: string
          format: date
          nullable: true
        entryCategory:
          type: string
          description: "What kind of entry it is (INVOICE, CREDIT_NOTE, PAYMENT, ...)."
          nullable: true
        erpDocumentId:
          type: string
          description: "The ERP's own key for the source document: text, not the id\
            \ of a document in /v1/documents."
        itemKey:
          type: string
          description: The source's stable key for the item.
        open:
          type: boolean
          description: Open today.
        openAsOf:
          type: boolean
          description: Open as of asOfDate.
        openItemId:
          type: string
          format: uuid
          description: "Open-item id: what list_comments' openItemId takes."
        partyKey:
          type: string
          description: The party's sub-ledger key.
        partyName:
          type: string
          description: "A display label, not a key (match on partyKey): the register's\
            \ value and description joined as \"value: description\", one of the two\
            \ when the other is empty or the same, else the party key. Usually \"\
            number: name\", but companies on Systima or Fiken read \"name: number\"\
            \ until those imports change. No field carries the bare number or name\
            \ on its own."
          nullable: true
        settledDate:
          type: string
          format: date
          description: "When the item was settled in full, if it was."
          nullable: true
        settlementStatus:
          type: string
          description: Settlement state today.
          enum:
          - OPEN
          - PARTIAL
          - SETTLED
          x-extensible-enum: true
        subLedgerType:
          type: string
          description: "The sub-ledger type: CUSTOMER or SUPPLIER."
          enum:
          - CUSTOMER
          - SUPPLIER
          example: CUSTOMER
          x-extensible-enum: true
        transactionAmount:
          type: number
          nullable: true
        transactionAmountOpen:
          type: number
          nullable: true
        transactionCurrency:
          type: string
          nullable: true
      required:
      - accountNumber
      - agingBucket
      - amount
      - amountOpen
      - amountOpenAsOf
      - commentCount
      - erpDocumentId
      - itemKey
      - open
      - openAsOf
      - openItemId
      - partyKey
      - settlementStatus
      - subLedgerType
    SubLedgerParty:
      type: object
      description: One party's open-item residual in a section at the end of the period;
        zero balances are included.
      properties:
        balance:
          type: number
          description: The party's residual at the end of the period.
        partyKey:
          type: string
          description: The party's key in the sub-ledger register. Match parties on
            it.
        partyName:
          type: string
          description: "A display label, not a key: the register's value and description\
            \ joined as \"value: description\", one of the two when the other is empty\
            \ or the same, else the party key. Usually \"number: name\", but the ERP\
            \ decides which field holds which: companies on Systima or Fiken read\
            \ \"name: number\" until those imports change. No field carries the bare\
            \ number or name on its own. Until 2026-11-23 this field held the register's\
            \ value only."
          nullable: true
      required:
      - balance
      - partyKey
    SubLedgerPolicy:
      type: object
      description: The accountant's saved policy for proving the account reconciled.
      nullable: true
      properties:
        balanceTolerance:
          type: number
          description: Largest acceptable control-vs-sub-ledger difference.
          nullable: true
        checkBalanceWithinTolerance:
          type: boolean
          description: "Check: the balance difference is within the tolerance."
        checkOverdueOpenItems:
          type: boolean
          description: "Check: no open item is overdue beyond maxOverdueDays."
        checkUnexplainedAndOverlap:
          type: boolean
          description: "Check: no untagged or double-counted balance."
        maxOverdueDays:
          type: integer
          format: int32
          description: Most days an open item may be past due.
          nullable: true
        side:
          type: string
          enum:
          - CUSTOMER
          - SUPPLIER
          nullable: true
          x-extensible-enum: true
        version:
          type: integer
          format: int32
          nullable: true
      required:
      - checkBalanceWithinTolerance
      - checkOverdueOpenItems
      - checkUnexplainedAndOverlap
    SubLedgerReconciliationResponse:
      type: object
      description: Sub-ledger vs general-ledger reconciliation per control account
        and sub-ledger type.
      properties:
        asOfDate:
          type: string
          format: date
          description: "The date the open-item evidence is computed for, when requested."
          nullable: true
        companyId:
          type: string
          format: uuid
        ledgerId:
          type: string
          format: uuid
          description: The ledger the balances were read from.
        period:
          type: integer
          format: int32
          description: "The cutoff: the end of this fiscal period (0-12; 0 = the fiscal\
            \ year's opening day). The control balance runs through it; the residuals\
            \ are as of it."
        sections:
          type: array
          items:
            $ref: "#/components/schemas/SubLedgerSection"
        year:
          type: integer
          format: int32
          description: Accounting year.
      required:
      - companyId
      - ledgerId
      - period
      - sections
      - year
    SubLedgerResponse:
      type: object
      description: "A sub-ledger party (customer, supplier, ...), identified by its\
        \ company-wide partyKey."
      properties:
        description:
          type: string
          nullable: true
        parentPartyKey:
          type: string
          description: "The parent party's partyKey, for hierarchies."
          nullable: true
        partyKey:
          type: string
          description: "The party's stable, company-wide key: the partyKey open items\
            \ and the sub-ledger reconciliation carry, and the partyKeys of general-ledger\
            \ lines and opening balances."
          example: C-1001
        type:
          type: string
          description: A free-form type label.
          example: customer
          nullable: true
        value:
          type: string
          description: The display value.
          example: Kunde AS
      required:
      - partyKey
      - value
    SubLedgerSection:
      type: object
      description: One control account × sub-ledger type.
      properties:
        accountName:
          type: string
          nullable: true
        accountNumber:
          type: string
          example: "1500"
        controlBalance:
          type: number
          description: The account's balance in the general ledger (opening balance
            + movements).
        differenceAmount:
          type: number
          description: "controlBalance minus subLedgerBalance. Non-zero means the\
            \ open items do not explain the ledger: items missing, or settled differently\
            \ than the ledger shows."
        openItems:
          type: array
          description: "Open items on the account as of asOfDate, per currency; present\
            \ when asOfDate was given."
          items:
            $ref: "#/components/schemas/OpenItemEvidence"
          nullable: true
        overlapAmount:
          type: number
          description: "Double-counted balance: lines tagged with more than one party\
            \ of this type."
        parties:
          type: array
          description: "Per-party balances, when includeParties was set; else empty."
          items:
            $ref: "#/components/schemas/SubLedgerParty"
        partyCount:
          type: integer
          format: int32
          description: Number of parties with a balance in the section.
        policy:
          $ref: "#/components/schemas/SubLedgerPolicy"
        subLedgerBalance:
          type: number
          description: The sum of the open items' residuals (what is still open) of
            this type on the account at the end of the period.
        subLedgerType:
          type: string
          description: "The sub-ledger type: CUSTOMER or SUPPLIER."
          enum:
          - CUSTOMER
          - SUPPLIER
          example: CUSTOMER
          x-extensible-enum: true
        verdict:
          type: string
          description: "BREAK when differenceAmount or overlapAmount is non-zero at\
            \ two decimals, else BALANCED."
          enum:
          - BALANCED
          - BREAK
          x-extensible-enum: true
      required:
      - accountNumber
      - controlBalance
      - differenceAmount
      - overlapAmount
      - parties
      - partyCount
      - subLedgerBalance
      - subLedgerType
      - verdict
    SubLedgerSync:
      type: object
      description: Sub-ledger open-item sync; null when the company has no ERP connected.
      properties:
        lastSyncedAt:
          type: string
          format: date-time
          nullable: true
        sides:
          type: array
          description: "The sub-ledger sides the ERP delivers open-item snapshots\
            \ for (CUSTOMER, SUPPLIER); a sync counts once every one of them has a\
            \ snapshot. Empty when unsupported."
          enum:
          - CUSTOMER
          - SUPPLIER
          items:
            type: string
            description: "The sub-ledger sides the ERP delivers open-item snapshots\
              \ for (CUSTOMER, SUPPLIER); a sync counts once every one of them has\
              \ a snapshot. Empty when unsupported."
            enum:
            - CUSTOMER
            - SUPPLIER
            x-extensible-enum: true
          x-extensible-enum: true
        snapshotAligned:
          type: boolean
          description: The open-item snapshot is at least as recent as the last GL
            fetch.
          nullable: true
        state:
          type: string
          description: "UNSUPPORTED, NOT_SYNCED, PENDING, ACKNOWLEDGED, RUNNING, COMPLETED,\
            \ FAILED, EXPIRED or SUPERSEDED."
          enum:
          - UNSUPPORTED
          - NOT_SYNCED
          - PENDING
          - ACKNOWLEDGED
          - RUNNING
          - COMPLETED
          - FAILED
          - EXPIRED
          - SUPERSEDED
          x-extensible-enum: true
        supported:
          type: boolean
          description: Whether the connected ERP delivers open-item snapshots.
      required:
      - sides
      - state
      - supported
    SubLedgersImportRequest:
      type: object
      properties:
        subLedgers:
          type: array
          items:
            $ref: "#/components/schemas/SubLedgerLine"
      required:
      - subLedgers
    SubjectKey:
      type: object
      description: "What a comment or flag is on, in the API's own ids. type says\
        \ which one field is set; the others are null. ACCOUNT: accountId. GL_LINE:\
        \ lineId (list_general_ledger_lines). OPENING_BALANCE: openingBalanceId (list_opening_balances).\
        \ OPEN_ITEM: openItemId (list_open_items). ACCRUAL: accrualId (list_accruals).\
        \ BANK_TRANSACTION: bankTransactionId (list_bank_transactions). INTERCOMPANY_DEFINITION:\
        \ definitionId (an intercompany pair's thread). COMPANY: companyId (the intercompany\
        \ module's thread or report note on the company itself). ASSET: assetId. ASSET_CATEGORY:\
        \ assetCategoryId. MONTH: yearMonth (an asset-register or payroll month).\
        \ OTHER: none (a subject this API does not name). list_comments and list_flags\
        \ filter by accountId, lineId, openingBalanceId, accrualId and bankTransactionId\
        \ under the same names (list_comments by openItemId too); the other ids are\
        \ no filter."
      properties:
        accountId:
          type: string
          format: uuid
          description: "ACCOUNT: the account (accountId, one per accounting year)."
          nullable: true
        accrualId:
          type: string
          format: uuid
          description: "ACCRUAL: the accrual's id (list_accruals)."
          nullable: true
        assetCategoryId:
          type: string
          format: uuid
          description: "ASSET_CATEGORY: the asset category's id."
          nullable: true
        assetId:
          type: string
          format: uuid
          description: "ASSET: the fixed asset's id."
          nullable: true
        bankTransactionId:
          type: string
          format: uuid
          description: "BANK_TRANSACTION: the bank transaction's id."
          nullable: true
        companyId:
          type: string
          format: uuid
          description: "COMPANY: the company the thread is on (the comment's own)."
          nullable: true
        definitionId:
          type: string
          format: uuid
          description: "INTERCOMPANY_DEFINITION: the intercompany definition's id."
          nullable: true
        lineId:
          type: string
          description: "GL_LINE: the general-ledger line's lineId."
          nullable: true
        openItemId:
          type: string
          format: uuid
          description: "OPEN_ITEM: the sub-ledger open item's openItemId."
          nullable: true
        openingBalanceId:
          type: string
          description: "OPENING_BALANCE: the opening balance's openingBalanceId."
          nullable: true
        type:
          type: string
          description: "The kind of subject, which says the one field that is set."
          enum:
          - ACCOUNT
          - GL_LINE
          - OPENING_BALANCE
          - OPEN_ITEM
          - ACCRUAL
          - BANK_TRANSACTION
          - INTERCOMPANY_DEFINITION
          - COMPANY
          - ASSET
          - ASSET_CATEGORY
          - MONTH
          - OTHER
          example: GL_LINE
          x-extensible-enum: true
        yearMonth:
          type: string
          description: "MONTH: the calendar month, YYYY-MM."
          example: 2026-03
          nullable: true
      required:
      - type
    SubledgerReconChecks:
      type: object
      properties:
        balanceWithinTolerance:
          type: boolean
          nullable: true
        overdueOpenItems:
          type: boolean
          nullable: true
        unexplainedAndOverlap:
          type: boolean
          nullable: true
    SubledgerReconRule:
      type: object
      description: How a customer or supplier control account is reconciled.
      nullable: true
      properties:
        balanceTolerance:
          type: number
          format: double
          description: Largest accepted difference.
          minimum: 0
        checks:
          $ref: "#/components/schemas/SubledgerReconChecks"
        maxOverdueDays:
          type: integer
          format: int32
          description: Days an open item may be overdue.
          minimum: 0
        side:
          type: string
          enum:
          - CUSTOMER
          - SUPPLIER
          x-extensible-enum: true
        version:
          type: integer
          format: int32
          description: Policy version; 1 when absent.
          maximum: 1
          minimum: 1
          nullable: true
      required:
      - balanceTolerance
      - checks
      - maxOverdueDays
      - side
    TaskAssignment:
      type: object
      description: "Who the task is assigned to, by whom and when."
      nullable: true
      properties:
        assignedAt:
          type: string
          format: date-time
          description: When.
        assignedBy:
          $ref: "#/components/schemas/PersonRef"
        assignee:
          $ref: "#/components/schemas/PersonRef"
      required:
      - assignedAt
    TaskChange:
      type: object
      description: The task's latest change.
      nullable: true
      properties:
        at:
          type: string
          format: date-time
          description: When it was recorded.
        correlationId:
          type: string
          description: The producer's correlation id.
          nullable: true
        initiatedBy:
          type: string
          description: "Who started the change behind it, as the producer named them\
            \ (for example user:<id>)."
          nullable: true
        kind:
          type: string
          description: What changed.
          enum:
          - STATUS
          - FRESHNESS
          - EVIDENCE
          - ASSIGNMENT
          - WORK_DUE
          x-extensible-enum: true
      required:
      - at
      - kind
    TaskDetailResponse:
      type: object
      description: "A task with its episodes and its latest transitions, newest first."
      properties:
        episodes:
          type: array
          description: "Every episode of the task, newest first."
          items:
            $ref: "#/components/schemas/TaskEpisode"
        task:
          $ref: "#/components/schemas/TaskResponse"
        transitions:
          type: array
          description: "The latest changes to the task, newest first, at most 50."
          items:
            $ref: "#/components/schemas/TaskTransition"
      required:
      - episodes
      - task
      - transitions
    TaskEpisode:
      type: object
      description: One episode of the task.
      properties:
        closedAt:
          type: string
          format: date-time
          description: When it closed; absent while it is open.
          nullable: true
        closedStatus:
          type: string
          description: How it closed.
          enum:
          - RESOLVED
          - NOT_APPLICABLE
          nullable: true
          x-extensible-enum: true
        number:
          type: integer
          format: int32
          description: The episode's number.
        openedAt:
          type: string
          format: date-time
          description: When it opened.
      required:
      - number
      - openedAt
    TaskEpisodeRef:
      type: object
      description: The task's current episode.
      properties:
        number:
          type: integer
          format: int32
          description: "The episode's number: 1, then one more each time the task\
            \ reopens."
        openedAt:
          type: string
          format: date-time
          description: When the episode opened.
      required:
      - number
      - openedAt
    TaskMyState:
      type: object
      description: Your private state on the task.
      nullable: true
      properties:
        hiddenAt:
          type: string
          format: date-time
          description: When you hid it; the lists leave it out.
          nullable: true
        readAt:
          type: string
          format: date-time
          description: When you read it.
          nullable: true
        snoozedUntil:
          type: string
          format: date-time
          description: Snoozed until then; the lists leave the task out until it passes.
          nullable: true
    TaskResponse:
      type: object
      description: "A system-generated task: one rule's finding on one target (the\
        \ company, one account or one intercompany definition) for one period."
      properties:
        accountNumber:
          type: string
          description: "The account's number when the target is an ACCOUNT (target.key):\
            \ accountNumber for get_account_reconciliation, with year."
          nullable: true
        assignment:
          $ref: "#/components/schemas/TaskAssignment"
        companyId:
          type: string
          format: uuid
          description: The company the task belongs to.
        definitionId:
          type: string
          format: uuid
          description: "The intercompany definition's id when the target is INTERCOMPANY\
            \ (target.key): definitionId for get_intercompany_definition."
          nullable: true
        dimension:
          type: string
          description: "What within the target the task is about, when a rule checks\
            \ several things on it (for example erp_source for G02); \"-\" when it\
            \ checks one."
        episode:
          $ref: "#/components/schemas/TaskEpisodeRef"
        evidence:
          type: object
        freshness:
          type: string
          description: "FRESH: the last evaluation was complete. STALE or UNKNOWN:\
            \ the status may be out of date (the last evaluation could not decide)."
          enum:
          - FRESH
          - STALE
          - UNKNOWN
          x-extensible-enum: true
        id:
          type: string
          format: uuid
          description: "The task's id: taskId for get_task. Stable across episodes:\
            \ a finding that comes back after it was resolved reopens the same task."
        lastChange:
          $ref: "#/components/schemas/TaskChange"
        lastEvaluatedAt:
          type: string
          format: date-time
          description: "When the rule last evaluated the task completely, also when\
            \ nothing changed."
        myState:
          $ref: "#/components/schemas/TaskMyState"
        period:
          type: integer
          format: int32
          description: "A term's number within its year, in periodType (TERM periods\
            \ only). A fiscal-year task (FY:<year>) has none: pick the period to read;\
            \ evidence.period names the one the rule judged where it has one."
          nullable: true
        periodKey:
          type: string
          description: "The period as the task service keys it: NONE, FY:<year> (an\
            \ accounting year) or TERM:<periodType>:<year>:<period> (a term, for example\
            \ TERM:BIMONTHLY:2026:5). The periodKey filter takes it back."
        periodType:
          type: string
          description: "A term's period type (TERM periods only). MONTHLY, BIMONTHLY,\
            \ QUARTERLY, TERTIARY, HALF_YEARLY and YEARLY are the cadences the close\
            \ reads take; HALF_MONTHLY, BIWEEKLY and WEEKLY_ISO are not."
          enum:
          - MONTHLY
          - BIMONTHLY
          - QUARTERLY
          - TERTIARY
          - HALF_YEARLY
          - YEARLY
          - HALF_MONTHLY
          - BIWEEKLY
          - WEEKLY_ISO
          nullable: true
          x-extensible-enum: true
        reasonCode:
          type: string
          description: "Why the rule decided as it did: a snake_case code of the rule\
            \ (for example rule_rejected, credentials_missing)."
          nullable: true
        rowVersion:
          type: integer
          format: int64
          description: "The version of the task's shared state; it changes with every\
            \ status, assignment or work-due change."
        rule:
          $ref: "#/components/schemas/TaskRule"
        status:
          type: string
          description: "OPEN and BLOCKED need work; RESOLVED, NOT_APPLICABLE, WAIVED,\
            \ SUPERSEDED and MANUAL_CLOSED do not."
          enum:
          - OPEN
          - BLOCKED
          - RESOLVED
          - WAIVED
          - SUPERSEDED
          - NOT_APPLICABLE
          - MANUAL_CLOSED
          x-extensible-enum: true
        target:
          $ref: "#/components/schemas/TaskTarget"
        workDue:
          $ref: "#/components/schemas/TaskWorkDue"
        year:
          type: integer
          format: int32
          description: "The year of periodKey: the accounting year of FY:<year>, the\
            \ term's own year of a TERM; absent for NONE."
          nullable: true
      required:
      - companyId
      - dimension
      - episode
      - evidence
      - freshness
      - id
      - lastEvaluatedAt
      - periodKey
      - rowVersion
      - rule
      - status
      - target
    TaskRule:
      type: object
      description: The rule that found the task.
      properties:
        code:
          type: string
          description: "The rule's code, for example L01, B04 or G02: the rule filter\
            \ takes it."
        descriptionKey:
          type: string
          description: The i18n key of the rule's description.
        family:
          type: string
          description: The area the rule checks; more may come.
          enum:
          - SETUP
          - BALANCE
          - LINKED_BALANCE
          - GENERAL_LEDGER
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - ACCRUALS
          - ASSETS
          - VAT
          - PAYROLL
          - INTERCOMPANY
          x-extensible-enum: true
        severity:
          type: string
          description: "HIGH, MEDIUM or LOW; lists sort on it."
          enum:
          - HIGH
          - MEDIUM
          - LOW
          x-extensible-enum: true
        titleKey:
          type: string
          description: "The i18n key of the rule's title, for a client's own catalog."
        version:
          type: integer
          format: int32
          description: The rule's version at its last evaluation.
      required:
      - code
      - descriptionKey
      - family
      - severity
      - titleKey
      - version
    TaskTarget:
      type: object
      description: What the task is about.
      properties:
        key:
          type: string
          description: "The target's key in its type: the targetKey filter takes it."
        type:
          type: string
          description: "COMPANY (the key is the company's id), ACCOUNT (the key is\
            \ the account number) or INTERCOMPANY (the key is the intercompany definition's\
            \ id)."
          enum:
          - COMPANY
          - ACCOUNT
          - INTERCOMPANY
          x-extensible-enum: true
      required:
      - key
      - type
    TaskTransition:
      type: object
      description: One recorded change to the task.
      properties:
        actorId:
          type: string
          description: The actor's id as the task service recorded it.
          nullable: true
        actorKind:
          type: string
          description: "SYSTEM (a rule's evaluation) or USER (a person, through Accountflow)."
          enum:
          - SYSTEM
          - USER
          x-extensible-enum: true
        correlationId:
          type: string
          description: The producer's correlation id.
          nullable: true
        episodeNumber:
          type: integer
          format: int32
          description: The episode it belongs to.
        evidence:
          type: object
        fromAssignee:
          $ref: "#/components/schemas/PersonRef"
        fromFreshness:
          type: string
          description: The freshness before.
          nullable: true
        fromStatus:
          type: string
          description: "The status before, for a STATUS change."
          enum:
          - OPEN
          - BLOCKED
          - RESOLVED
          - WAIVED
          - SUPERSEDED
          - NOT_APPLICABLE
          - MANUAL_CLOSED
          nullable: true
          x-extensible-enum: true
        initiatedBy:
          type: string
          description: "Who started the change behind it, as the producer named them."
          nullable: true
        kind:
          type: string
          description: What changed.
          enum:
          - STATUS
          - FRESHNESS
          - EVIDENCE
          - ASSIGNMENT
          - WORK_DUE
          x-extensible-enum: true
        reasonCode:
          type: string
          description: The rule's reason code at this change.
          nullable: true
        recordedAt:
          type: string
          format: date-time
          description: When it was recorded.
        toAssignee:
          $ref: "#/components/schemas/PersonRef"
        toFreshness:
          type: string
          description: The freshness after.
          nullable: true
        toStatus:
          type: string
          description: "The status after, for a STATUS change."
          enum:
          - OPEN
          - BLOCKED
          - RESOLVED
          - WAIVED
          - SUPERSEDED
          - NOT_APPLICABLE
          - MANUAL_CLOSED
          nullable: true
          x-extensible-enum: true
      required:
      - actorKind
      - episodeNumber
      - evidence
      - kind
      - recordedAt
    TaskWorkDue:
      type: object
      description: "The internal work due date: not a statutory deadline."
      nullable: true
      properties:
        at:
          type: string
          format: date-time
          description: When the work is due.
        source:
          type: string
          description: "Who set it: a person (USER), the rule (RULE) or a policy (POLICY)."
          enum:
          - RULE
          - USER
          - POLICY
          x-extensible-enum: true
      required:
      - at
      - source
    TrialBalanceAccount:
      type: object
      description: "One account's opening balance, monthly movements, and closing\
        \ balance."
      properties:
        accountId:
          type: string
          format: uuid
          description: "This accounting year's account (as list_accounts returns it):\
            \ every accounting year has a new id, so keep accountNumber + year as\
            \ the stable key."
        accountNumber:
          type: string
          example: "3000"
        category:
          type: string
          nullable: true
        closingBalance:
          type: number
          description: Balance at the end of the year.
        name:
          type: string
          nullable: true
        openingBalance:
          type: number
          description: Balance at the start of the year.
        periods:
          type: array
          description: Monthly movements (NOT running balances).
          items:
            $ref: "#/components/schemas/PeriodMovement"
      required:
      - accountId
      - accountNumber
      - closingBalance
      - openingBalance
      - periods
    TrialBalanceImportRequest:
      type: object
      properties:
        rows:
          type: array
          description: "One row per account and month: the closing balance at the\
            \ month's end, and for balance-sheet accounts the year's opening balance\
            \ on any of its rows."
          items:
            $ref: "#/components/schemas/TrialBalanceRow"
        year:
          type: integer
          format: int32
          description: The accounting year the trial balance covers.
          example: 2025
      required:
      - rows
      - year
    TrialBalanceResponse:
      type: object
      description: Trial balance for one accounting year.
      properties:
        accounts:
          type: array
          description: "This page's accounts, by account number."
          items:
            $ref: "#/components/schemas/TrialBalanceAccount"
        companyId:
          type: string
          format: uuid
          description: The company.
        ledgerId:
          type: string
          format: uuid
          description: The ledger this balance was read from (one per company × year).
        pagination:
          $ref: "#/components/schemas/Pagination"
        totals:
          $ref: "#/components/schemas/TrialBalanceTotals"
        year:
          type: integer
          format: int32
          description: Accounting year.
      required:
      - accounts
      - companyId
      - ledgerId
      - pagination
      - totals
      - year
    TrialBalanceRow:
      type: object
      description: One account's closing balance at the end of one month of the accounting
        year.
      properties:
        accountCode:
          type: string
          description: The account's code in the chart of accounts. An account the
            chart does not have yet is created with accountDescription as its name.
          example: "1920"
        accountDescription:
          type: string
          description: "The account's name, used when the import creates the account.\
            \ The first non-blank one of an account's rows is used."
          example: Bankinnskudd
          nullable: true
        closingBalance:
          type: string
          description: "The account's balance at the end of the month, in the company's\
            \ base currency, as a decimal string (a JSON number is also accepted).\
            \ Balance-sheet accounts carry the balance including the opening balance;\
            \ result accounts the year to date."
          example: "125000.0"
        openingBalance:
          type: string
          description: "The account's opening balance for the year. Only balance-sheet\
            \ accounts (classes 1 and 2) have one; it is ignored for result accounts.\
            \ Left out, the previous year's closing balance is used, else what is\
            \ stored, else 0."
          example: "100000.0"
          nullable: true
        period:
          type: integer
          format: int32
          description: "Month of the accounting year, 1-12: the calendar month when\
            \ the year starts in January."
          example: 3
      required:
      - accountCode
      - closingBalance
      - period
    TrialBalanceTotals:
      type: object
      description: Sums across all accounts.
      properties:
        closingBalance:
          type: number
        openingBalance:
          type: number
      required:
      - closingBalance
      - openingBalance
    UpdateAccountSettingsRequest:
      type: object
      properties:
        amountToleranceNok:
          type: number
          maximum: 100
          minimum: 0
          nullable: true
        autoApprove:
          type: boolean
          nullable: true
        autoPostOnHighConfidence:
          type: boolean
          nullable: true
        automationEnabled:
          type: boolean
          nullable: true
        balanceRecon:
          $ref: "#/components/schemas/BalanceReconRule"
        documentationRequired:
          type: boolean
          nullable: true
        hidden:
          type: boolean
          nullable: true
        matchRules:
          $ref: "#/components/schemas/MatchRules"
        matchWindowDays:
          type: integer
          format: int32
          maximum: 365
          minimum: 0
          nullable: true
        maxGroupSize:
          type: integer
          format: int32
          maximum: 100
          minimum: 0
          nullable: true
        minConfidenceScore:
          type: integer
          format: int32
          maximum: 100
          minimum: 0
          nullable: true
        overrideCompanyDefaults:
          type: boolean
          nullable: true
        ownerUserId:
          type: string
          format: uuid
          nullable: true
        requireExactCounterparty:
          type: boolean
          nullable: true
        reset:
          type: array
          description: "Fields to clear or inherit again (owner, the rules, documentationRequired,\
            \ matchWindowDays, the automation values)."
          items:
            type: string
            description: "Fields to clear or inherit again (owner, the rules, documentationRequired,\
              \ matchWindowDays, the automation values)."
          nullable: true
        secondPassEnabled:
          type: boolean
          nullable: true
        secondPassMaxOpenLines:
          type: integer
          format: int32
          maximum: 10000
          minimum: 0
          nullable: true
        secondPassWindowDays:
          type: integer
          format: int32
          maximum: 365
          minimum: 0
          nullable: true
        settingsRevision:
          type: integer
          format: int64
          description: The settingsRevision a read returned.
        subledgerRecon:
          $ref: "#/components/schemas/SubledgerReconRule"
        templateType:
          type: string
          description: How the account is reconciled.
          nullable: true
      required:
      - settingsRevision
    UpdateCompanyAutomationModuleRequest:
      type: object
      properties:
        autoApprove:
          type: boolean
          description: "Let finished runs approve this module's reconciled accounts\
            \ without a person; never while the module's own automatic reconciliation\
            \ is off. Not for CURRENCY_K28 or CURRENCY_K29, which never approve: only\
            \ false is accepted back."
          nullable: true
        bankGlCorrectionsEnabled:
          type: boolean
          description: "BANK only: a last round that pairs a ledger posting with its\
            \ reversal (same date, same amount, opposite sign) that no bank line took,\
            \ saved as a correction. Inherited, it is on."
          nullable: true
        bankSecondPassEnabled:
          type: boolean
          description: "BANK only: a last round with a wide window that makes exact-amount\
            \ pairs and groups (a pair needs a single candidate on each side, a group\
            \ no interchangeable same-amount line). Inherited, it is off."
          nullable: true
        bankSecondPassWindowDays:
          type: integer
          format: int32
          description: "BANK only: the days apart the bank second pass's pairs and\
            \ groups may span. Inherited, it is 30."
          maximum: 365
          minimum: 0
          nullable: true
        enabled:
          type: boolean
          description: "Run automatic reconciliation for this module. Never while\
            \ the company's is off, except VAT and PAYROLL, which run unless switched\
            \ off here. CURRENCY_K28 and CURRENCY_K29 run only when switched on here\
            \ (and the company's runs)."
          nullable: true
        expectedVersion:
          type: string
          maxLength: 64
          nullable: true
        flagAbsoluteNok:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, NOK, 0 to 1000000000,\
            \ at most 2 decimals: a deviation above it is flagged whatever the percentage.\
            \ Inherited, it is 1000."
          maximum: 1000000000
          minimum: 0
          nullable: true
        flagFloorNok:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, NOK, 0 to 1000000000,\
            \ at most 2 decimals: the deviation a flag needs beside flagPercent. Inherited,\
            \ it is 10."
          maximum: 1000000000
          minimum: 0
          nullable: true
        flagPercent:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, 0 to 100, at most 2 decimals:\
            \ the deviation in percent of the expected amount above which, together\
            \ with flagFloorNok, a finding is flagged. Inherited, it is 1."
          maximum: 100
          minimum: 0
          nullable: true
        groupWindowDays:
          type: integer
          format: int32
          description: "BANK only: the days the lines of a group (one ledger line\
            \ against several bank lines, or the reverse) may be apart. Inherited,\
            \ it is the module's match window."
          maximum: 365
          minimum: 0
          nullable: true
        highFloorNok:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, NOK, 0 to 1000000000,\
            \ at most 2 decimals, not below the effective flagFloorNok: the deviation\
            \ a high flag needs. Inherited, it is 100."
          maximum: 1000000000
          minimum: 0
          nullable: true
        highPercent:
          type: number
          description: "CURRENCY_K28 and CURRENCY_K29 only, 0 to 100, at most 2 decimals,\
            \ not below the effective flagPercent: the percentage of a high flag.\
            \ Inherited, it is 5."
          maximum: 100
          minimum: 0
          nullable: true
        matchWindowDays:
          type: integer
          format: int32
          description: "This module's first-pass window in days; for BANK the days\
            \ a bank line and a ledger line of the same amount may be apart. Not for\
            \ SIMPLE_BANK, BALANCE, ASSETS, VAT, PAYROLL, CURRENCY_K28 or CURRENCY_K29,\
            \ which match no lines."
          maximum: 365
          minimum: 0
          nullable: true
        reset:
          type: array
          description: Fields to return to the inherited value.
          items:
            type: string
            enum:
            - enabled
            - matchWindowDays
            - secondPassEnabled
            - autoApprove
            - groupWindowDays
            - bankSecondPassEnabled
            - bankSecondPassWindowDays
            - bankGlCorrectionsEnabled
            - flagPercent
            - flagFloorNok
            - flagAbsoluteNok
            - highPercent
            - highFloorNok
          maxItems: 13
          nullable: true
        secondPassEnabled:
          type: boolean
          description: "The general second pass. Not for BANK (see bankSecondPassEnabled)\
            \ nor SIMPLE_BANK, BALANCE, ASSETS, VAT, PAYROLL, CURRENCY_K28 or CURRENCY_K29,\
            \ which have none; for those only the value get_company_settings shows\
            \ is accepted back, and reset clears an old value."
          nullable: true
    UpdateCompanyAutomationRequest:
      type: object
      properties:
        amountToleranceNok:
          type: number
          maximum: 100
          minimum: 0
          nullable: true
        autoApprove:
          type: boolean
          nullable: true
        autoPostOnHighConfidence:
          type: boolean
          nullable: true
        autoReconcile:
          type: boolean
          nullable: true
        dayTolerance:
          type: integer
          format: int32
          maximum: 365
          minimum: 0
          nullable: true
        expectedVersion:
          type: string
          maxLength: 64
          nullable: true
        frequency:
          type: string
          enum:
          - DAILY
          - EVERY_OTHER_DAY
          - WEEKLY
          - MONTHLY
          nullable: true
        maxGroupSize:
          type: integer
          format: int32
          maximum: 100
          minimum: 0
          nullable: true
        minConfidenceScore:
          type: integer
          format: int32
          maximum: 100
          minimum: 0
          nullable: true
        requireExactCounterparty:
          type: boolean
          nullable: true
        secondPassEnabled:
          type: boolean
          nullable: true
        secondPassMaxOpenLines:
          type: integer
          format: int32
          maximum: 10000
          minimum: 0
          nullable: true
        secondPassWindowDays:
          type: integer
          format: int32
          maximum: 365
          minimum: 0
          nullable: true
        suggestionsEnabled:
          type: boolean
          nullable: true
    UpdateCompanyContactRequest:
      type: object
      properties:
        defaultRecipient:
          type: boolean
          nullable: true
        email:
          type: string
          maxLength: 254
          nullable: true
        expectedVersion:
          type: string
          description: The version the contacts read returned; refused with 409 if
            they changed since.
          maxLength: 64
          nullable: true
        fullName:
          type: string
          maxLength: 200
          nullable: true
        phone:
          type: string
          description: An empty string removes the phone number.
          maxLength: 50
          nullable: true
        roles:
          type: array
          items:
            type: string
          nullable: true
    UpdateCompanyRequest:
      type: object
      properties:
        companyNumber:
          type: string
          maxLength: 32
          nullable: true
        companyType:
          type: string
          maxLength: 32
          nullable: true
        countryCode:
          type: string
          description: ISO 3166-1 alpha-2.
          maxLength: 2
          nullable: true
          pattern: "^[A-Za-z]{2}$"
        fiscalYearEnd:
          type: string
          format: date
          deprecated: true
          description: "Deprecated: use fiscalYearStartMonth. Accepted when it ends\
            \ the twelve months from fiscalYearStart and implies the company's current\
            \ start month; otherwise 422."
          nullable: true
        fiscalYearStart:
          type: string
          format: date
          deprecated: true
          description: "Deprecated: use fiscalYearStartMonth. Accepted when it is\
            \ the first day of a month and gives the company's current start month;\
            \ otherwise 422."
          nullable: true
        fiscalYearStartMonth:
          type: integer
          format: int32
          description: "Month (1-12) the company's fiscal years start in. Only the\
            \ company's current month is accepted (a no-op); a different month is\
            \ 422: change the fiscal year in Accountflow, which also moves the company's\
            \ years that hold no postings."
          example: 1
          maximum: 12
          minimum: 1
          nullable: true
        name:
          type: string
          maxLength: 255
          nullable: true
        periodType:
          type: string
          nullable: true
    UpdateCompanySettingsRequest:
      type: object
      properties:
        assetsEnabled:
          type: boolean
          nullable: true
        auditorUserId:
          type: string
          format: uuid
          nullable: true
        automation:
          $ref: "#/components/schemas/CompanyAutomationChange"
        controllerUserId:
          type: string
          format: uuid
          nullable: true
        currencyAccountingYear:
          type: integer
          format: int32
          description: "The accounting year currencyCode is for; absent: the company's\
            \ current accounting year. The change reaches that year and later years\
            \ without a code of their own; other years that have a ledger, and the\
            \ current year, keep the code they had. Only with currencyCode."
          maximum: 2999
          minimum: 1900
          nullable: true
        currencyCode:
          type: string
          description: "Base currency, ISO 4217, recorded as a company setting for\
            \ currencyAccountingYear. 409 conflict (reason base_currency_from_erp)\
            \ when the company's ERP reports another base currency directly for that\
            \ same year. Inherited ERP values remain editable. Nothing already booked\
            \ is recalculated."
          maxLength: 3
          nullable: true
          pattern: "^[A-Za-z]{3}$"
        expectedVersion:
          type: string
          description: The version a read returned; refused with 409 if the settings
            changed since.
          maxLength: 64
          nullable: true
        intercompanyEnabled:
          type: boolean
          nullable: true
        mainAccountantUserId:
          type: string
          format: uuid
          nullable: true
        ownerUserId:
          type: string
          format: uuid
          nullable: true
        payrollEnabled:
          type: boolean
          nullable: true
        reset:
          type: array
          description: Responsible people to unassign; the owner can be replaced but
            not removed.
          items:
            type: string
            enum:
            - controller
            - mainAccountant
            - auditor
          maxItems: 3
          nullable: true
        vatEnabled:
          type: boolean
          nullable: true
    UpdateIntercompanyDefinitionRequest:
      type: object
      properties:
        active:
          type: boolean
          description: false deactivates the link (kept with its accounts); true reactivates
            it.
          nullable: true
        allowPartialSettlement:
          type: boolean
          nullable: true
        expectedVersion:
          type: string
          description: The version the read returned (the groups' for a new link);
            refused with 409 if it changed since.
          maxLength: 64
          nullable: true
        signConvention:
          type: string
          enum:
          - SUM_ZERO
          - SAME_SIGN
          nullable: true
    UpdateIntercompanyLineRequest:
      type: object
      properties:
        expectedVersion:
          type: string
          description: The version the read returned (the groups' for a new link);
            refused with 409 if it changed since.
          maxLength: 64
          nullable: true
        lineType:
          type: string
          nullable: true
        name:
          type: string
          description: An empty string removes the name.
          maxLength: 200
          nullable: true
        pairingKey:
          type: string
          format: uuid
          nullable: true
        sortOrder:
          type: integer
          format: int32
          minimum: 0
          nullable: true
    UpdatePolicyRequest:
      type: object
      properties:
        description:
          type: string
          maxLength: 2000
          nullable: true
        isDefault:
          type: boolean
          deprecated: true
          description: "Legacy flag: the organization default policy is retired and\
            \ grants nothing. true is refused (400, reason default_policy_retired),\
            \ except on an update of a policy that already carries it (an echo of\
            \ what was read); false clears a stored flag."
          nullable: true
        name:
          type: string
          maxLength: 200
          nullable: true
        rules:
          type: array
          items:
            $ref: "#/components/schemas/RuleInput"
          maxItems: 500
          nullable: true
    UpdateWebhookRequest:
      type: object
      properties:
        description:
          type: string
          maxLength: 500
          nullable: true
        eventTypes:
          type: array
          items:
            type: string
            maxLength: 100
          maxItems: 100
          nullable: true
        url:
          type: string
          maxLength: 2048
          nullable: true
    Upload:
      type: object
      description: "Where and how to upload the binary — directly to storage, not\
        \ through the API."
      properties:
        contentType:
          type: string
          description: The Content-Type header the PUT must carry (it is part of the
            signature).
        expiresAt:
          type: string
          format: date-time
        headers:
          type: object
          additionalProperties:
            type: string
            description: "Every header the PUT must carry, exactly as given: they\
              \ are part of the signature, and storage refuses the upload without\
              \ them. Besides Content-Type: x-goog-content-length-range (the body\
              \ may not exceed the declared sizeBytes) and x-goog-if-generation-match:\
              \ 0 (the URL only creates the file, it cannot replace it)."
            example: "{\"Content-Type\":\"application/pdf\",\"x-goog-content-length-range\"\
              :\"0,48213\",\"x-goog-if-generation-match\":\"0\"}"
          description: "Every header the PUT must carry, exactly as given: they are\
            \ part of the signature, and storage refuses the upload without them.\
            \ Besides Content-Type: x-goog-content-length-range (the body may not\
            \ exceed the declared sizeBytes) and x-goog-if-generation-match: 0 (the\
            \ URL only creates the file, it cannot replace it)."
          example:
            Content-Type: application/pdf
            x-goog-content-length-range: "0,48213"
            x-goog-if-generation-match: "0"
        method:
          type: string
          example: PUT
        url:
          type: string
          description: Signed PUT URL for the binary.
      required:
      - contentType
      - expiresAt
      - headers
      - method
      - url
    UserResponse:
      type: object
      description: A user of the organization.
      properties:
        createdAt:
          type: string
          format: date-time
          description: When the user was registered.
          nullable: true
        email:
          type: string
          nullable: true
        firstName:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
          description: The user's stable identifier.
        lastName:
          type: string
          nullable: true
        phone:
          type: string
          nullable: true
        role:
          type: string
          description: "Membership role in this organization: ADMIN, MEMBER or EXTERNAL."
          enum:
          - ADMIN
          - MEMBER
          - EXTERNAL
          example: MEMBER
          x-extensible-enum: true
        status:
          type: string
          description: Lifecycle state.
          enum:
          - ACTIVE
          - DISABLED
          example: ACTIVE
          x-extensible-enum: true
      required:
      - id
      - role
      - status
    UserState:
      type: object
      description: The acting person's own state for the item; null for machine clients.
      properties:
        assigneeId:
          type: string
          format: uuid
          nullable: true
        assigneeName:
          type: string
          nullable: true
        hidden:
          type: boolean
          description: "DONE, or SNOOZED and not yet due back — hidden from the default\
            \ queue."
        snoozedUntil:
          type: string
          format: date-time
          nullable: true
        status:
          type: string
          description: "OPEN, DONE or SNOOZED."
          enum:
          - OPEN
          - DONE
          - SNOOZED
          x-extensible-enum: true
      required:
      - hidden
      - status
    VatTermResponse:
      type: object
      description: A VAT filing term and its current status.
      properties:
        calculatedTotal:
          type: number
          description: Calculated VAT total for the term (NOK).
          nullable: true
        difference:
          type: number
          description: calculated − filed (NOK).
          nullable: true
        filedTotal:
          type: number
          description: Filed VAT total per the tax authority (NOK).
          nullable: true
        id:
          type: string
          format: uuid
          description: The term's stable identifier.
        periodEnd:
          type: string
          format: date
          description: Last day of the term.
          nullable: true
        periodStart:
          type: string
          format: date
          description: First day of the term.
          nullable: true
        sequence:
          type: integer
          format: int32
          description: Term sequence within the year (1-based).
          example: 3
        status:
          type: string
          description: "Reconciliation status. Common values: approved_for_sending,\
            \ sent_to_egov, approved, reopened; earlier worker-side statuses may also\
            \ appear."
          nullable: true
        year:
          type: integer
          format: int32
          description: Filing year.
          example: 2026
      required:
      - id
      - sequence
      - year
    VoucherResponse:
      type: object
      description: "A voucher (bilag): its header, line count and size."
      properties:
        debitTotal:
          type: number
          description: Sum of the positive line amounts — one side of the double entry.
        description:
          type: string
          description: The voucher text.
          nullable: true
        firstPeriod:
          type: integer
          format: int32
          description: First period among its lines.
          nullable: true
        journalType:
          type: string
          description: "The source journal the ERP encoded in the number (GL, AP,\
            \ AR, ...); absent when the ERP encodes none."
          nullable: true
        lastPeriod:
          type: integer
          format: int32
          description: Last period among its lines (differs when it spans periods).
          nullable: true
        lineCount:
          type: integer
          format: int32
          description: General-ledger lines on the voucher.
        sourceDocumentId:
          type: string
          description: The ERP's document reference.
          nullable: true
        voucherDate:
          type: string
          format: date
          nullable: true
        voucherId:
          type: string
          format: uuid
          description: Voucher id.
        voucherKey:
          type: string
          description: "The ERP's key for the voucher, which every one of its general-ledger\
            \ lines carries (their voucherKey): the value a document's VOUCHER association\
            \ takes. Absent when the lines carry none, or more than one."
          nullable: true
        voucherNo:
          type: string
          description: The voucher number as the ERP numbers it.
          nullable: true
        year:
          type: integer
          format: int32
          description: The accounting year of its lines.
          nullable: true
      required:
      - debitTotal
      - lineCount
      - voucherId
    WebhookDeliveryResponse:
      type: object
      description: One delivery attempt log for an endpoint (self-debugging surface).
      properties:
        attempts:
          type: integer
          format: int32
        createdAt:
          type: string
          format: date-time
        deliveredAt:
          type: string
          format: date-time
          nullable: true
        eventId:
          type: string
          format: uuid
          description: The event this delivery carries — dedupe on this.
        eventType:
          type: string
        id:
          type: string
          format: uuid
          description: The delivery's identifier (retries share it).
        lastError:
          type: string
          nullable: true
        lastStatusCode:
          type: integer
          format: int32
          nullable: true
        payload:
          type: object
          description: The payload as it was (or will be) POSTed — the signed event
            envelope.
        status:
          type: string
          description: PENDING | DELIVERED | DEAD. A delivery cancelled because its
            endpoint was deleted or disabled before it went out is DEAD with lastError
            starting with "cancelled:" and no lastStatusCode.
          enum:
          - PENDING
          - DELIVERED
          - DEAD
          example: DELIVERED
          x-extensible-enum: true
      required:
      - attempts
      - createdAt
      - eventId
      - eventType
      - id
      - payload
      - status
    WebhookEndpointCreatedResponse:
      type: object
      description: A newly registered (or secret-rotated) endpoint. The secret appears
        ONLY here — store it now.
      properties:
        endpoint:
          $ref: "#/components/schemas/WebhookEndpointResponse"
        secret:
          type: string
          description: The HMAC signing secret. Shown exactly once; rotate to get
            a new one.
      required:
      - endpoint
      - secret
    WebhookEndpointResponse:
      type: object
      description: A webhook endpoint registration.
      properties:
        createdAt:
          type: string
          format: date-time
        description:
          type: string
          nullable: true
        disabledReason:
          type: string
          description: "Why the endpoint was disabled, when status is DISABLED."
          nullable: true
        eventTypes:
          type: array
          description: Subscribed event types; empty = every event type.
          items:
            type: string
            description: Subscribed event types; empty = every event type.
        id:
          type: string
          format: uuid
          description: The endpoint's stable identifier.
        status:
          type: string
          description: PENDING_VERIFICATION | ACTIVE | DISABLED. New endpoints must
            answer the verification challenge before deliveries start; repeated delivery
            failure auto-disables an endpoint.
          enum:
          - PENDING_VERIFICATION
          - ACTIVE
          - DISABLED
          example: ACTIVE
          x-extensible-enum: true
        url:
          type: string
      required:
      - createdAt
      - eventTypes
      - id
      - status
      - url
    WhoamiResponse:
      type: object
      description: The authenticated principal's identity and scope.
      properties:
        clientId:
          type: string
          description: The integration's client id (the token's azp).
          example: com.acme.erp-sync
        mode:
          type: string
          description: "How this principal acts: SYSTEM, USER (headless, as its linked\
            \ human), INTERACTIVE (a person, e.g. via an MCP client), or DELEGATED\
            \ (an internal service acting as the person named per request)."
          enum:
          - SYSTEM
          - USER
          - INTERACTIVE
          - DELEGATED
          example: SYSTEM
          x-extensible-enum: true
        organizationId:
          type: string
          format: uuid
          description: The organization whose subtree this client reaches. Null for
            INTERACTIVE and DELEGATED principals — a person's reach is their org memberships.
          nullable: true
        organizationIds:
          type: array
          description: "For INTERACTIVE and DELEGATED principals, the organizations\
            \ the person belongs to — the tenants their calls can reach. Null for\
            \ machine clients, whose single organization is organizationId."
          items:
            type: string
            format: uuid
            description: "For INTERACTIVE and DELEGATED principals, the organizations\
              \ the person belongs to — the tenants their calls can reach. Null for\
              \ machine clients, whose single organization is organizationId."
            nullable: true
          nullable: true
        userId:
          type: string
          format: uuid
          description: "The human every check runs as: the linked user for USER mode,\
            \ the signed-in person for INTERACTIVE, the acting user for DELEGATED.\
            \ Null for SYSTEM — a machine acts as itself."
          nullable: true
      required:
      - clientId
      - mode
    WorkQueueItemResponse:
      type: object
      description: One item of the close work queue.
      properties:
        accountId:
          type: string
          format: uuid
          description: The account's id (null on accrual items).
          nullable: true
        accountName:
          type: string
          nullable: true
        accountNumber:
          type: string
          nullable: true
        amount:
          type: number
          description: "ACCRUALS_NEED_CONFIRMATION: the suggested accrual's total\
            \ amount."
          nullable: true
        companyId:
          type: string
          format: uuid
        companyName:
          type: string
        daysOverdue:
          type: integer
          format: int32
          description: Whole days past the due date; null when not past due.
          nullable: true
        description:
          type: string
          description: "ACCRUALS_NEED_CONFIRMATION: the suggestion's description."
          nullable: true
        dueDate:
          type: string
          format: date
          description: "When the work was due: the period's last day plus 10 days."
          nullable: true
        id:
          type: string
          description: Stable key of the item across calls (core's queue item id).
        missingYear:
          type: integer
          format: int32
          description: "ACCRUAL_YEARS_MISSING: the accounting year that was never\
            \ imported."
          nullable: true
        openLines:
          type: integer
          format: int32
          description: "ACCRUAL_YEARS_MISSING: unclaimed lines waiting on that year."
          nullable: true
        priority:
          type: string
          description: "CRITICAL (past due), HIGH (drifted, or a missing year), MEDIUM\
            \ (review work)."
          enum:
          - CRITICAL
          - HIGH
          - MEDIUM
          - LOW
          x-extensible-enum: true
        remainingCount:
          type: integer
          format: int32
          description: "ACCRUALS_NEED_CONFIRMATION_MORE: suggestions not listed individually."
          nullable: true
        score:
          type: integer
          format: int32
          description: "ACCRUALS_NEED_CONFIRMATION: the suggestion's confidence score."
          nullable: true
        stale:
          type: boolean
          description: The account's approval has drifted since it was given.
        staleReasons:
          type: array
          items:
            type: string
        suggestionId:
          type: string
          format: uuid
          description: "ACCRUALS_NEED_CONFIRMATION: the accrual suggestion's id."
          nullable: true
        type:
          type: string
          description: "UNRECONCILED_ACCOUNT (past due or drifted after approval),\
            \ ACCRUAL_YEARS_MISSING (the prior year was never imported), ACCRUALS_NEED_CONFIRMATION\
            \ (one accrual suggestion awaiting a decision), ACCRUALS_NEED_CONFIRMATION_MORE\
            \ (the suggestions beyond the first three)."
          enum:
          - UNRECONCILED_ACCOUNT
          - ACCRUAL_YEARS_MISSING
          - ACCRUALS_NEED_CONFIRMATION
          - ACCRUALS_NEED_CONFIRMATION_MORE
          x-extensible-enum: true
        userState:
          $ref: "#/components/schemas/UserState"
      required:
      - companyId
      - companyName
      - id
      - priority
      - stale
      - staleReasons
      - type
      - userState
    Year:
      type: object
      description: What one accounting year's ledger holds.
      properties:
        accounts:
          type: integer
          format: int64
        current:
          type: boolean
          description: Whether this is the company's current accounting year.
        generalLedgerLines:
          type: integer
          format: int64
        lastImportAt:
          type: string
          format: date-time
          description: When the latest successful import or correction for this year
            finished.
          nullable: true
        mappedAccounts:
          type: integer
          format: int64
          description: Accounts mapped to a standard account.
        openingBalances:
          type: integer
          format: int64
        year:
          type: integer
          format: int32
      required:
      - accounts
      - current
      - generalLedgerLines
      - mappedAccounts
      - openingBalances
      - year
  securitySchemes:
    oauth2:
      description: "OAuth 2.0 client credentials against the Accountflow Keycloak\
        \ realm. Exchange your API client's id and secret for a bearer token (see\
        \ Authentication), then send it on every request. What the token may do comes\
        \ from the scopes granted when the client was provisioned, not from the token\
        \ request. Don't send `scope` on the token request: a client's scopes come\
        \ from its registration in Bridge, not from the token."
      flows:
        clientCredentials:
          scopes:
            access:manage: Manage access policies
            audit:read: Read the organization's audit log
            bank:read: Read bank data
            companies:read: Read companies
            companies:write: Manage companies
            documents:read: Read documents
            documents:write: Manage documents
            imports:write: Push and correct ledger data for API-managed companies
            ledger:read: "Read GL, accounts, trial balances"
            reconciliation:read: Read reconciliation status
            reconciliation:run: Order account-scoped reconciliation runs
            reconciliation:write: Work with reconciliations
            settings:read: Read company settings
            settings:write: Change company settings
            users:read: Read organization users
            vat:read: Read VAT status and returns
            webhooks:manage: Manage webhook endpoints
          tokenUrl: https://auth.prod.accountflow.com/realms/accountflow/protocol/openid-connect/token
      type: oauth2
x-tagGroups:
- name: Getting started
  tags:
  - Authentication
  - Identity
  - Jobs
- name: Organisation & access
  tags:
  - Organizations
  - Portfolios
  - Companies
  - Users
  - Access Management
  - Audit log
  - Webhooks
- name: Ledger data
  tags:
  - General Ledger
  - Sub-ledgers
  - VAT
- name: Reconciliation & close
  tags:
  - Close
  - Tasks
  - Company status
  - Account detail
  - Reconciliation runs
  - Settlements
  - Bank & Reconciliation
- name: Configuration
  tags:
  - Company settings
  - Account settings
  - Account mapping
  - Account templates
  - Routines
  - Contacts
  - Intercompany
- name: Documents
  tags:
  - Documents
- name: Data import
  tags:
  - Imports
- name: Collaboration
  tags:
  - Collaboration
