openapi: 3.0.1
info:
  description: Accountflow's public API for external integrations.
  title: Accountflow Bridge API
  version: 1.0.0-rc1
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: "Bank accounts, transactions, and bank↔GL reconciliation"
  name: Bank & Reconciliation
- description: VAT filing terms and their status
  name: VAT
- description: Settlements (utligninger) of general-ledger lines on an account
  name: Settlements
- description: "Opening balances, accruals and reconciliation adjustments of an account"
  name: Account detail
- description: "What happened on an account: approvals, comments, settlements, ..."
  name: Account activity
- description: Comments and flags on reconciliation subjects
  name: Collaboration
- description: Document metadata; binaries via signed URLs
  name: Documents
- description: "Customer and supplier open items, aging, and sub-ledger reconciliation"
  name: Sub-ledgers
- 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: "Chart of accounts, GL lines, and trial balances"
  name: General Ledger
- description: "Signed event notifications — poke, then fetch"
  name: Webhooks
- description: The accounting clients (companies) within your reach
  name: Companies
- 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: 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
        next_cursor; 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - companies:read
      summary: Get a company
      tags:
      - Companies
    patch:
      description: "Patch semantics: absent fields stay unchanged."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - companies:write
      summary: Update a company
      tags:
      - Companies
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - reconciliation:read
      summary: Get an account's activity history
      tags:
      - Account activity
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Map many accounts to standard accounts
      tags:
      - Company settings
  /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 within periodType: 1-12 for MONTHLY, 1-4 for QUARTERLY,\
          \ …"
        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
      - 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: UNRECONCILED | APPROVED | RECONCILED | DEVIATION | STALE | OPEN
          | FUTURE | NOT_APPLICABLE.
        in: query
        name: status
        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/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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: Get the company's account template
      tags:
      - Company settings
    patch:
      description: "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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Choose the company's account template
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Apply the company's account template to its accounts
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: Preview applying the company's account template
      tags:
      - Company settings
  /v1/companies/{companyId}/accounts:
    get:
      description: "The company's accounts for one accounting year. Omit `year` for\
        \ the current accounting year. Accounts are identified by their account number,\
        \ which is stable across years."
      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
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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
      - 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Take an account off its standard account
      tags:
      - Company settings
    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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Map an account to a standard account
      tags:
      - Company settings
  /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 within periodType: 1-12 for MONTHLY, 1-4 for QUARTERLY,\
          \ …"
        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
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Remove the company's own routine from an account
      tags:
      - Company settings
    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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Write the company's own routine on an account
      tags:
      - Company settings
  /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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: Get one account's routines
      tags:
      - Company settings
  /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
      - 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Switch a routine on or off for an account
      tags:
      - Company settings
  /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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: Get one account's settings
      tags:
      - Company 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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Change one account's settings
      tags:
      - Company 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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Return an account to the automation defaults
      tags:
      - Company 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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: Where an account's settings came from
      tags:
      - Company settings
  /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: 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Use the template's value for one of an account's settings
      tags:
      - Company settings
  /v1/companies/{companyId}/accrual-suggestions:
    get:
      description: "Ordered by account, then score. Each carries the exact schedule\
        \ accepting it would create."
      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
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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."
      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: MONTHLY | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
      - description: "The period within the year, in periodType."
        in: query
        name: period
        required: true
        schema:
          type: integer
          format: int32
      - description: Year to date instead of the period alone.
        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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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.
        in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - description: "With year: only approvals overlapping this period."
        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
      - description: APPROVED | REVOKED.
        in: query
        name: status
        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/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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - reconciliation:read
      summary: List account approvals
      tags:
      - Close
  /v1/companies/{companyId}/bank/accounts:
    get:
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - bank:read
      summary: List the company's bank accounts
      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."
      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
      - in: query
        name: year
        required: true
        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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - reconciliation:read
      summary: Per-period reconciliation summary
      tags:
      - Bank & Reconciliation
  /v1/companies/{companyId}/bank/accounts/{bankAccountId}/reconciliations:
    get:
      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
      - in: query
        name: year
        required: false
        schema:
          type: integer
          format: int32
      - in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - reconciliation:read
      summary: List reconciliation groups for a bank account
      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
      - in: query
        name: from
        required: false
        schema:
          type: string
          format: date
      - in: query
        name: to
        required: false
        schema:
          type: string
          format: date
      - description: unreconciled | reconciled | stale.
        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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - bank:read
      summary: List bank transactions
      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. 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"
            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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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 within periodType: 1-12 for MONTHLY, 1-4 for QUARTERLY,\
          \ …"
        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
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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 (periodYear,\
        \ periodType, period) is all-or-none; at most one subject filter."
      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.
        in: query
        name: commentType
        required: false
        schema:
          type: string
      - description: Account-balance comments on this account (resolved in periodYear's
          ledger).
        in: query
        name: accountNumber
        required: false
        schema:
          type: string
      - in: query
        name: periodYear
        required: false
        schema:
          type: integer
          format: int32
      - description: MONTHLY | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
      - 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: "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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: List a company's contacts
      tags:
      - Company settings
    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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Add a company contact
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Change a company contact
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Deactivate a company contact
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Reactivate a company contact
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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\
        \ from and to (default: the next 90 days), soonest first. Due dates are rolled\
        \ to the next business day."
      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: from
        required: false
        schema:
          type: string
          format: date
      - description: "Last due date to include (ISO date); default from + 90 days,\
          \ max + 366."
        in: query
        name: to
        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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - imports:write
      summary: Delete an unused dimension value
      tags:
      - Imports
  /v1/companies/{companyId}/documents:
    get:
      description: "Oldest first, cursor-paginated. Optional filters: `search` (words\
        \ in the file name); the attachment — `associationType` (account, transaction,\
        \ gl_line, company, recon_run, erp_ledger) with `associationId` (an account\
        \ number — resolved in `periodYear`'s ledger — or account id, a voucher's\
        \ transaction key, a GL line id — its voucher's documents — or the company/run/ledger\
        \ id); for account attachments a period (`periodYear`, 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: search
        required: false
        schema:
          type: string
      - description: account | transaction | gl_line | company | recon_run | erp_ledger.
        in: query
        name: associationType
        required: false
        schema:
          type: string
      - 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: periodYear
        required: false
        schema:
          type: integer
          format: int32
      - description: MONTHLY | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
      - description: Period within periodYear (with periodType).
        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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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.
        in: query
        name: itemType
        required: false
        schema:
          type: string
      - 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.
        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: "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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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 and its attachment count. 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: account
        required: false
        schema:
          type: string
      - description: Filter to one fiscal period (1–12).
        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: "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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - imports:write
      summary: Check import readiness
      tags:
      - Imports
  /v1/companies/{companyId}/imports/sub-ledgers:
    post:
      description: "Push up to 10 000 sub-ledgers (customers, suppliers, ...). Keys\
        \ are company-wide and stable; an existing key 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - imports:write
      summary: Import sub-ledgers
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: List the company's intercompany counterparty links
      tags:
      - Company settings
    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"
            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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Link the company to an intercompany counterparty
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: Get one intercompany counterparty link
      tags:
      - Company settings
    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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Change an intercompany counterparty link
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Put an account on a counterparty link
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Take an account off a counterparty link
      tags:
      - Company settings
    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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Move an account to another line of the same link
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Add a reconciliation line to a counterparty link
      tags:
      - Company settings
  /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
      - 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Delete an empty reconciliation line
      tags:
      - Company settings
    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
      - 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:write
      summary: Change a reconciliation line
      tags:
      - Company settings
  /v1/companies/{companyId}/intercompany/groups:
    get:
      description: "The groups the company belongs to and their members: the counterparties\
        \ it can link to."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: List the company's intercompany groups
      tags:
      - Company settings
  /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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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."
      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: MONTHLY | BIMONTHLY | QUARTERLY | TERTIARY | HALF_YEARLY | YEARLY.
        in: query
        name: periodType
        required: false
        schema:
          type: string
      - description: "The period within the year, in periodType."
        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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - reconciliation:read
      summary: List an account-period's reconciliation adjustments
      tags:
      - Account detail
  /v1/companies/{companyId}/reconciliations/{reconciliationId}:
    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: reconciliationId
        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/ReconciliationDeletionResult"
          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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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: reconciliationId
        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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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; fields named in reset inherit the
        company default again.
      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
      - 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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
      - description: The settlement's period; with periodType.
        in: query
        name: period
        required: false
        schema:
          type: integer
          format: int32
      - description: auto | manual.
        in: query
        name: type
        required: false
        schema:
          type: string
      - description: settled | partial.
        in: query
        name: status
        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/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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - reconciliation:read
      summary: List settlements on an account
      tags:
      - Settlements
  /v1/companies/{companyId}/standard-accounts:
    get:
      description: The standard accounts of the company's country.
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - settings:read
      summary: List the standard accounts a company can map to
      tags:
      - Company settings
  /v1/companies/{companyId}/sub-ledgers:
    get:
      description: "The company's sub-ledgers (customers, suppliers, ...) by their\
        \ stable, company-wide keys — the keys general-ledger lines and open items\
        \ refer to."
      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/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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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.
        in: query
        name: subLedgerType
        required: false
        schema:
          type: string
      - description: One party's sub-ledger key.
        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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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: "Cumulative through this period, 0–12 (0 = opening balance only)."
        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.
        in: query
        name: subLedgerType
        required: false
        schema:
          type: string
      - 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - reconciliation:read
      summary: Reconcile sub-ledgers against their control accounts
      tags:
      - Sub-ledgers
  /v1/companies/{companyId}/sub-ledgers/{key}:
    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
      - 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - imports:write
      summary: Delete an unused sub-ledger
      tags:
      - Imports
  /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."
      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
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - ledger:read
      summary: Get the trial balance
      tags:
      - General Ledger
  /v1/companies/{companyId}/vat/terms:
    get:
      description: The company's VAT filing terms with their reconciliation status
        and totals (decimal NOK).
      operationId: listVatTerms
      parameters:
      - in: path
        name: companyId
        required: true
        schema:
          type: string
          format: uuid
      - description: Filter to one filing 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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: Period within year (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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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 within periodType: 1-12 for MONTHLY, 1-4 for QUARTERLY,\
          \ …"
        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
      - 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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/DocumentDeletionResult"
          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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - documents:write
      summary: Restore a deleted document
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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.
        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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2: []
      summary: Get a job's status
      tags:
      - Jobs
  /v1/organizations/{organizationId}/access-policies:
    get:
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - access:manage
      summary: List access policies
      tags:
      - Access Management
    post:
      description: "The policy is one document: name, default flag, and its rules.\
        \ Marking it default demotes the previous default."
      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"
            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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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. 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). 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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 all assigned policies
        plus the organization's default policy.
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - access:manage
      summary: Revoke a user's assignment
      tags:
      - Access Management
  /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"
            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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - companies:write
      summary: Create a company
      tags:
      - Companies
  /v1/organizations/{organizationId}/users:
    get:
      description: Members of the organization. Disabled users are listed with status
        'disabled'; deleted users are not represented.
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - users:read
      summary: Get one user
      tags:
      - Users
  /v1/organizations/{organizationId}/users/{userId}/effective-access:
    get:
      description: "The user's merged access per company: the strongest role any active\
        \ policy or direct assignment grants, the account scope, and the specific\
        \ account ids where scoped. A user who is not a member of the organization\
        \ is a 404."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - users:read
      summary: Get one user's effective access
      tags:
      - Users
  /v1/organizations/{organizationId}/webhooks:
    get:
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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"
            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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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/WebhookEndpointDeletionResult"
          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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "409":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: An import of this kind is already running for the company
                    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: a duplicate resource, another in-flight request\
            \ with this Idempotency-Key (idempotency_in_flight, with Retry-After),\
            \ a blocking job (jobId), or a state that refuses the change — `reason`\
            \ says which."
          headers:
            Retry-After:
              $ref: "#/components/headers/Retry-After"
        "413":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: lines holds 12000 lines; the limit is 10000 per request
                    error: payload_too_large
                    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."
        "422":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: 3 lines refer to account codes missing from the chart
                    error: unprocessable
                    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 a semantic rule failed\
            \ — `reason` and `errors` say which."
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      security:
      - oauth2:
        - webhooks:manage
      summary: List delivery attempts
      tags:
      - Webhooks
  /v1/portfolios/{portfolioId}/account-status:
    get:
      description: "Per member company: reconcilable accounts, reconciled accounts,\
        \ reconciled percentage and open accounts for one period."
      operationId: listPortfolioAccountStatus
      parameters:
      - in: path
        name: portfolioId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year.
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      - description: "Period within periodType: 1-12 for MONTHLY, 1-4 for QUARTERLY,\
          \ …"
        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
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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.
      operationId: listPortfolioCloseStatus
      parameters:
      - in: path
        name: portfolioId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year.
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      - description: "Period within periodType: 1-12 for MONTHLY, 1-4 for QUARTERLY,\
          \ …"
        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
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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."
      operationId: listPortfolioWorkQueue
      parameters:
      - in: path
        name: portfolioId
        required: true
        schema:
          type: string
          format: uuid
      - description: Accounting year.
        in: query
        name: year
        required: true
        schema:
          type: integer
          format: int32
      - description: "Period within periodType: 1-12 for MONTHLY, 1-4 for QUARTERLY,\
          \ …"
        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
      - 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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  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 tenant scope. Absence and lack
            of access are deliberately indistinguishable.
        "429":
          content:
            application/problem+json:
              examples:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      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:
                problem:
                  value:
                    detail: year is required and must be between 1900 and 2100
                    error: validation_failed
                    requestId: d4f0a1b2-…
                    status: 400
                    title: Validation Failed
                    type: https://api.accountflow.com/errors/validation-failed
              schema:
                $ref: "#/components/schemas/Problem"
          description: Malformed request — a required field is missing or a value
            is out of range. The `detail` names the field.
        "401":
          content:
            application/problem+json:
              examples:
                problem:
                  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:
                problem:
                  value:
                    detail: Scope ledger:read is required
                    error: insufficient_scope
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Rate limit exceeded
                    error: rate_limited
                    requestId: d4f0a1b2-7c3e-4f5a-9b6d-8e1f2a3b4c5d
                    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:
                problem:
                  value:
                    detail: Unexpected error
                    error: internal_error
                    requestId: d4f0a1b2-…
                    status: 500
                    title: Internal Server 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:
                problem:
                  value:
                    detail: Authorization service 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: "A dependency the decision needs (the authorization service,\
            \ the context service) is unavailable; the call was refused rather than\
            \ allowed. Retry with backoff."
      summary: Who am I
      tags:
      - Identity
components:
  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:
    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
          description: "The org's baseline policy, applied to every member on top\
            \ of explicit grants."
        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
      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
        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."
          nullable: 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
          example: ACTIVE
        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.
          example: core
        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.
          example: comment
      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
          nullable: 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
      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).
        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.
        lineId:
          type: string
          description: The opening balance's stable id (what comments and flags refer
            to).
        openItem:
          $ref: "#/components/schemas/OpeningBalanceOpenItem"
        origin:
          type: string
          description: "ERP (imported), SPLIT (an item specified in the app) or MANUAL\
            \ (imported item)."
          example: ERP
        parentLineId:
          type: string
          description: The aggregate this item specifies; absent for an aggregate
            or plain line.
          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: "Settlement state: open, settled or partial (as for general-ledger\
            \ lines)."
          enum:
          - open
          - settled
          - partial
        settlementType:
          type: string
          enum:
          - auto
          - manual
          nullable: true
        sourceAmount:
          type: number
          description: The amount as imported.
        specifiedAmount:
          type: number
          description: How much of an aggregate its items specify (0 without items).
        subLedgerKeys:
          type: array
          description: Sub-ledger (party) keys the balance is tagged with.
          items:
            type: string
            description: Sub-ledger (party) keys the balance is tagged with.
        transactionAmount:
          type: number
          nullable: true
        transactionCurrency:
          type: string
          nullable: true
        year:
          type: integer
          format: int32
          description: The accounting year the balance is carried into.
      required:
      - accountNumber
      - amount
      - dimensionKeys
      - hasChildren
      - lineId
      - origin
      - settlementStatus
      - sourceAmount
      - specifiedAmount
      - subLedgerKeys
      - 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"
        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, STALE, OPEN or FUTURE — as in the account\
            \ status list."
          enum:
          - RECONCILED
          - DEVIATION
          - STALE
          - OPEN
          - FUTURE
        templateType:
          type: string
        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 (general ledger accounts only);
            null inherits.
          nullable: true
        overrideCompanyDefaults:
          type: boolean
          description: Whether the automation values below override the module and
            company defaults.
        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.
          nullable: 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
        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,\
            \ …)."
          nullable: true
        stale:
          type: boolean
        staleReasons:
          type: array
          description: "One code per drifted fact, e.g. BALANCE_CHANGED, PERIOD_TYPE_CHANGED."
          items:
            type: string
            description: "One code per drifted fact, e.g. BALANCE_CHANGED, PERIOD_TYPE_CHANGED."
        status:
          type: string
          description: "RECONCILED (approved, no deviation), DEVIATION (approved,\
            \ balance differs), STALE (approved, but evidence changed since), OPEN\
            \ (not approved), FUTURE (the period has not started), NOT_APPLICABLE\
            \ (reconciled on its own page: VAT, payroll, assets)."
          enum:
          - RECONCILED
          - DEVIATION
          - STALE
          - OPEN
          - FUTURE
          - NOT_APPLICABLE
        templateType:
          type: string
          description: "The account's reconciliation template, e.g. BANK, GENERAL_LEDGER_BALANCE,\
            \ ACCRUALS."
          nullable: 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
      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 (normalized: numbers as strings)."
          nullable: true
        field:
          type: string
          description: "template_type, is_documentation_required, balance_recon, subledger_recon,\
            \ automation or match_rules."
      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
        periodYear:
          type: integer
          format: int32
          nullable: true
        role:
          type: string
          description: "BASIS, RECOGNITION or ADJUSTMENT."
        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
      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
        periodYear:
          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."
      required:
      - amount
      - period
      - periodYear
      - status
    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.
        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."
        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:
        adjustmentId:
          type: string
          format: uuid
        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
      required:
      - adjustmentId
      - amount
      - createdAt
    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+
        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
    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
        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
        approvedByName:
          type: string
          nullable: true
        companyId:
          type: string
          format: uuid
        period:
          type: integer
          format: int32
        periodType:
          type: string
        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), linked_balance_reconciliation, or null for\
            \ a manual approval."
          nullable: 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
        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
        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
        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.
      required:
      - approvalId
      - approvedAutomatically
      - 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 (transaction)."
      nullable: true
      properties:
        type:
          type: string
          example: transaction
        value:
          type: string
          description: "The company id, or the voucher's transaction key."
      required:
      - type
      - value
    AssociationInput:
      type: object
      properties:
        type:
          type: string
          enum:
          - company
          - transaction
          example: transaction
        value:
          type: string
          description: Required for 'transaction'; ignored for 'company'.
          maxLength: 200
          nullable: true
      required:
      - type
    AttachedTo:
      type: object
      description: "An attachment target: the whole company, one voucher (transaction),\
        \ 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."
          nullable: true
        periodYear:
          type: integer
          format: int32
          description: "Account documents only: the year the document belongs to."
          nullable: true
        type:
          type: string
          description: "company, transaction, account, recon_run or erp_ledger."
          example: transaction
        value:
          type: string
          description: "The company id, the voucher's transaction key, the account\
            \ id (as accountId elsewhere), the run id or the ledger id."
      required:
      - type
      - value
    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:
        account:
          type: string
          description: "ratio_vs_account: the account to compare against."
          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
        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
        relation:
          type: string
          description: "account_match: how the two balances relate."
          enum:
          - equal
          - opposite
          nullable: 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
        source:
          type: string
          description: "register_match: the register figure to compare against."
          enum:
          - regnskapsregisteret.innskutt_egenkapital
          - enhetsregisteret.aksjekapital
          nullable: true
      required:
      - method
    BankAccount:
      type: object
      description: A bank account connected to the company.
      properties:
        accountNumber:
          type: string
          nullable: true
        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
        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
        iban:
          type: string
          nullable: true
        id:
          type: string
          format: uuid
          description: The account's stable identifier.
        name:
          type: string
          nullable: true
        status:
          type: string
          description: The bank account's state as reported by the bank feed.
          example: active
      required:
      - id
      - status
    BankEntry:
      type: object
      description: One matched bank transaction.
      properties:
        amount:
          type: number
        transactionId:
          type: string
          format: uuid
      required:
      - amount
      - transactionId
    BankTransaction:
      type: object
      description: A bank transaction with its computed reconciliation state.
      properties:
        amount:
          type: number
          description: Signed amount; debits are negative.
        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.
        reconciliationId:
          type: string
          format: uuid
          description: "The reconciliation group, when matched."
          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
        remittanceInfo:
          type: string
          nullable: true
        source:
          type: string
          description: provider_api | file_upload.
        status:
          type: string
          enum:
          - booked
          - pending
          example: booked
        valueDate:
          type: string
          format: date
          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
        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
      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; null follows the
            organization's default.
          nullable: true
        expectedVersion:
          type: string
          description: The version the read returned; refused with 409 if the choice
            changed since.
          maxLength: 64
          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
        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, or a sub-ledger open item."
      properties:
        accountNumber:
          type: string
          description: "The account number, for account-addressed comments."
          nullable: true
        authorKind:
          type: string
          description: USER | SYSTEM.
          example: USER
        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 (other types written in the app are listed
            as stored).
          example: GL_BALANCE_RECON
        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 (or email).
          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.
          nullable: true
        periodYear:
          type: integer
          format: int32
          description: Fiscal year of the period scope (account-balance comments only).
          nullable: true
        source:
          type: string
          description: Machine source of a SYSTEM comment.
          nullable: true
        subjectKey:
          type: object
          additionalProperties:
            type: object
            description: "The subject exactly as stored — one key: account_map_uuid,\
              \ gl_af_id, opening_balance_af_id or subledger_open_item_id."
          description: "The subject exactly as stored — one key: account_map_uuid,\
            \ gl_af_id, opening_balance_af_id or subledger_open_item_id."
      required:
      - authorKind
      - comment
      - commentType
      - createdAt
      - id
      - mentions
      - subjectKey
    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."
          items:
            $ref: "#/components/schemas/CompanyAutomationModuleChange"
          maxItems: 6
          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.
          nullable: true
        enabled:
          type: boolean
          description: Run automatic reconciliation for this module (never when the
            company's is off).
          nullable: true
        matchWindowDays:
          type: integer
          format: int32
          description: "This module's first-pass window in days. Not for SIMPLE_BANK\
            \ or BALANCE, which match no lines."
          maximum: 365
          minimum: 0
          nullable: true
        module:
          type: string
          enum:
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - GENERAL_LEDGER
          - BALANCE
          - ACCRUALS
        reset:
          type: array
          description: Fields to return to the company default.
          items:
            type: string
            enum:
            - enabled
            - matchWindowDays
            - secondPassEnabled
            - autoApprove
          maxItems: 4
        secondPassEnabled:
          type: boolean
          description: "Not for SIMPLE_BANK or BALANCE, which match no lines."
          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
        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
      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
      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"
        version:
          type: string
          description: Pass back as expectedVersion to change the contacts.
      required:
      - companyId
      - data
      - 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.
        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.
          example: MONTHLY
          nullable: true
        status:
          type: string
          description: "Lifecycle state: 'active' or 'disabled'. Deleted companies\
            \ are not represented — they 404 until restored."
          enum:
          - active
          - disabled
          example: active
      required:
      - createdAt
      - fiscalYearEnd
      - fiscalYearStart
      - 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
        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
        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
    Coverage:
      type: object
      description: How the period is covered by standing approvals.
      properties:
        state:
          type: string
          enum:
          - NONE
          - PARTIAL
          - FULL
        validFrom:
          type: string
          format: date
        validTo:
          type: string
          format: date
      required:
      - state
      - validFrom
      - validTo
    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
          nullable: true
        fiscalYearStart:
          type: string
          format: date
          nullable: true
        mainAccountantUserId:
          type: string
          format: uuid
          nullable: true
        name:
          type: string
          maxLength: 255
        obMonth:
          type: integer
          format: int32
          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
          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
        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
        periodYear:
          type: integer
          format: int32
          maximum: 9998
          minimum: 1900
        transactionIds:
          type: array
          items:
            type: string
            format: uuid
          maxItems: 500
          nullable: true
      required:
      - bankAccountId
      - period
      - periodYear
    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."
          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
        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
        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 (soft) deletion; restore is available via POST
        /restore.
      properties:
        deletedAt:
          type: string
          format: date-time
        id:
          type: string
          format: uuid
        status:
          type: string
          enum:
          - deleted
          example: deleted
      required:
      - deletedAt
      - id
      - status
    DimensionsImportRequest:
      type: object
      properties:
        dimensions:
          type: array
          items:
            $ref: "#/components/schemas/MasterLine"
      required:
      - dimensions
    DocumentDeletionResult:
      type: object
      description: Confirmation of a (soft) deletion; restore via POST /actions/restore.
      properties:
        id:
          type: string
          format: uuid
        status:
          type: string
          enum:
          - deleted
          example: deleted
      required:
      - id
      - status
    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 (transaction), 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
    EffectiveAccessResponse:
      type: object
      description: One company's merged effective access for a user.
      properties:
        accountIds:
          type: array
          description: Account ids when accountScope is SPECIFIED; empty otherwise.
          items:
            type: string
            format: uuid
            description: Account ids when accountScope is SPECIFIED; empty otherwise.
        accountScope:
          type: string
          example: ALL
        companyId:
          type: string
          format: uuid
        role:
          type: string
          example: ACCOUNTANT
      required:
      - accountIds
      - accountScope
      - companyId
      - role
    Failure:
      type: object
      description: "Failed or expired fetches and failed imports of the last 30 days,\
        \ newest first."
      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
        status:
          type: string
        type:
          type: string
          description: The fetch kind or the dataset import type.
          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
        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."
          nullable: 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 (or email).
          nullable: true
        id:
          type: string
          format: uuid
          description: Flag id.
        itemType:
          type: string
          description: ACCOUNT | GL_LINE | ACCRUAL | OPENING_BALANCE.
          example: GL_LINE
        subjectKey:
          type: object
          additionalProperties:
            type: object
            description: "The flagged item exactly as stored — one key: account_id,\
              \ gl_af_id, accrual_uuid or opening_balance_af_id."
          description: "The flagged item exactly as stored — one key: account_id,\
            \ gl_af_id, accrual_uuid or opening_balance_af_id."
      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."
          nullable: true
      required:
      - currency
      - date
      - found
      - quoteCurrency
    GlEntry:
      type: object
      description: One matched GL line (by its stable line id).
      properties:
        amount:
          type: number
        lineId:
          type: string
          description: The GL line's stable identity.
      required:
      - amount
      - lineId
    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
        period:
          type: integer
          format: int32
          description: Fiscal period 1–12.
          example: 3
        postedDate:
          type: string
          format: date
          nullable: true
        subLedgerKeys:
          type: array
          items:
            type: string
            nullable: true
          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
        transactionId:
          type: string
          description: The transaction (voucher) id this line belongs to.
          example: V-2025-0456
        transactionNo:
          type: string
          description: The voucher number as shown to accountants.
          example: "456"
      required:
      - accountCode
      - amount
      - id
      - period
      - transactionId
      - transactionNo
    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).
        attachmentCount:
          type: integer
          format: int32
          description: Active ERP attachments (vedlegg) on the line's voucher.
        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).
        period:
          type: integer
          format: int32
          description: Fiscal period 1–12.
        postedDate:
          type: string
          format: date
          description: Posting date (bokføringsdato).
          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: "Settlement (utligning) state: open = in no settlement; settled\
            \ = in a settlement whose difference is below 0.05 (rounding); partial\
            \ = in a settlement that leaves a remainder."
          enum:
          - open
          - settled
          - partial
        settlementType:
          type: string
          description: "Who made the settlement: auto (the automatcher) or manual;\
            \ absent when open."
          enum:
          - auto
          - manual
          nullable: 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
        subLedgerKeys:
          type: array
          description: "Keys of the sub-ledger entries (customers, suppliers) the\
            \ line is tagged with."
          items:
            type: string
            description: "Keys of the sub-ledger entries (customers, suppliers) the\
              \ line is tagged with."
        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
        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
      - period
      - settlementStatus
      - subLedgerKeys
      - 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). 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
    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)."
          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)."
        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
          example: import_accounts
        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)."
          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)."
        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 (the\
            \ request's preconditions no longer held when its job ran), 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
          - account_deletion
          - dimension_deletion
          - sub_ledger_deletion
          - opening_balances_deletion
          - general_ledger_lines_deletion
        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
        result:
          type: object
        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
        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
      properties:
        inherited:
          type: boolean
        value:
          type: boolean
      required:
      - inherited
      - value
    InheritableInteger:
      type: object
      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
        method:
          type: string
          description: "ACCOUNT (the whole account), SUBLEDGER (one sub-ledger party)\
            \ or DIMENSION."
        subLedgerKey:
          type: string
          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
        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"
      required:
      - companyId
      - data
    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"
        version:
          type: string
          description: Pass back as expectedVersion to link a counterparty.
      required:
      - companyId
      - data
      - 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."
        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
    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
        result:
          type: object
        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
        type:
          type: string
          description: "The job type, e.g. import.<kind> for imports and corrections."
          example: import.general_ledger_lines
      required:
      - createdAt
      - id
      - params
      - result
      - status
      - type
    LedgerAccountResponse:
      type: object
      description: An account in the company's chart of accounts for one accounting
        year.
      properties:
        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"
        reconciliationFrequency:
          type: string
          description: "How often the account is reconciled (MONTHLY, BIMONTHLY, QUARTERLY,\
            \ TERTIARY, HALF_YEARLY, YEARLY); absent = no reconciliation cadence."
          example: MONTHLY
          nullable: true
        saftCode:
          type: string
          description: "The mapped Norwegian SAF-T standard account code, when mapped."
          example: "3000"
          nullable: true
        templateType:
          type: string
          description: "The reconciliation template the account follows (GENERAL_LEDGER_BALANCE,\
            \ BANK, SUB_LEDGER, ACCRUALS, ...)."
          example: GENERAL_LEDGER_BALANCE
        year:
          type: integer
          format: int32
          description: The accounting year this chart belongs to.
          example: 2026
      required:
      - accountNumber
      - documentationRequired
      - hasActivity
      - templateType
      - 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
        periodYear:
          type: integer
          format: int32
          description: Fiscal year.
          nullable: true
        role:
          type: string
          description: "BASIS or RECOGNITION, as the engine proposes."
          nullable: true
        text:
          type: string
          description: Line text.
          nullable: true
        transactionDate:
          type: string
          format: date
          description: Transaction date.
          nullable: true
        transactionNo:
          type: string
          description: Voucher/transaction number.
          nullable: true
      required:
      - lineId
    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: Required when the link has more than one line.
          nullable: true
        method:
          type: string
          enum:
          - ACCOUNT
          - SUBLEDGER
          - DIMENSION
        subLedgerKey:
          type: string
          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 or a sub-ledger, 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
        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
        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 name as written into the comment (full name, else email)."
        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:
      - displayName
      - length
      - startOffset
      - userId
    ModuleAutomationSettings:
      type: object
      properties:
        autoApprove:
          $ref: "#/components/schemas/InheritableBoolean"
        enabled:
          $ref: "#/components/schemas/InheritableBoolean"
        matchWindowDays:
          $ref: "#/components/schemas/InheritableInteger"
        module:
          type: string
          enum:
          - BANK
          - SIMPLE_BANK
          - SUB_LEDGER
          - GENERAL_LEDGER
          - BALANCE
          - ACCRUALS
        secondPassEnabled:
          $ref: "#/components/schemas/InheritableBoolean"
      required:
      - autoApprove
      - enabled
      - matchWindowDays
      - module
      - secondPassEnabled
    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
      required:
      - lineId
    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
    OpenItemsImportRequest:
      type: object
      properties:
        fromDate:
          type: string
          format: date
          nullable: true
        items:
          type: array
          description: "Open items in the import contract's shape (itemKey, subLedgerKey,\
            \ subLedgerType, accountCode, documentId, entryCategory, documentDate,\
            \ amount, amountOpen, settlementStatus, optional documentNo, dueDate,\
            \ settledDate, currencyCode, transactionAmount, transactionAmountOpen,\
            \ transactionCurrencyCode, sourceDeleted, description, matches[])."
          items:
            type: object
        mode:
          type: string
          description: "baseline | incremental | full | full_refresh: snapshot modes\
            \ retire what is absent; incremental only touches what is sent."
          enum:
          - baseline
          - incremental
          - full
          - full_refresh
          example: incremental
        subLedgerType:
          type: string
          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, party\
            \ key, item id."
          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
        subLedgerKeys:
          type: array
          items:
            type: string
            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
        documentId:
          type: string
        documentNo:
          type: string
          nullable: true
        dueDate:
          type: string
          format: date
          nullable: true
        entryCategory:
          type: string
          nullable: true
        itemId:
          type: string
          format: uuid
          description: Open-item id (as in list_open_items).
        partyKey:
          type: string
        partyType:
          type: string
          description: customer or supplier.
          nullable: true
      required:
      - documentId
      - itemId
      - partyKey
    OpeningBalancesImportRequest:
      type: object
      properties:
        lines:
          type: array
          items:
            $ref: "#/components/schemas/OpeningBalanceLine"
        year:
          type: integer
          format: int32
      required:
      - lines
      - year
    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
    PageBankAccount:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/BankAccount"
        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
    PageCompanyResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CompanyResponse"
        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
    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
    PageMasterDataResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/MasterDataResponse"
        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
    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
    PageSettlementResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/SettlementResponse"
        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
      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.
        periodYear:
          type: integer
          format: int32
          description: Fiscal year.
        recognitionLineId:
          type: string
          description: "The GL line recognizing this slice, when recognized."
          nullable: true
        status:
          type: string
          description: PLANNED | RECOGNIZED.
      required:
      - amount
      - period
      - periodYear
      - status
    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:
        approvalStatus:
          type: string
          description: "The firm's sign-off on the mapped GL account for this month:\
            \ APPROVED when an active attestation covers it, REVOKED when the latest\
            \ one was withdrawn; null = never approved (or no GL mapping)."
          enum:
          - APPROVED
          - REVOKED
          nullable: true
        bankEntryCount:
          type: integer
          format: int32
        glEntryCount:
          type: integer
          format: int32
        groupCount:
          type: integer
          format: int32
        hasStale:
          type: boolean
          description: Any group in the period has gone stale.
        period:
          type: integer
          format: int32
      required:
      - 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:
        companyId:
          type: string
          format: uuid
        companyName:
          type: string
        openAccounts:
          type: integer
          format: int32
          description: Accounts not yet reconciled.
        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 accounts in the period.
      required:
      - companyId
      - companyName
      - openAccounts
      - reconciledAccounts
      - reconciledPercent
      - totalAccounts
    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.
      properties:
        accountCodes:
          type: array
          description: "422 unknown_account_codes: the codes missing from the year's\
            \ chart."
          items:
            type: string
          nullable: true
        detail:
          type: string
          description: Human-readable specifics
        error:
          type: string
          description: Stable machine code (see the error catalog)
        errors:
          type: array
          description: Field-level problems for 400/422 answers.
          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
        inUse:
          type: array
          description: "409 on corrections: the objects 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
        jobId:
          type: string
          format: uuid
          description: "409 job_in_flight: the job that blocks this one."
          nullable: true
        limit:
          type: integer
          description: "413: the per-request cap that was exceeded."
          nullable: true
        parameter:
          type: string
          description: "400: the query or path parameter that was invalid."
          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. Branch on it; never on `detail`."
          nullable: true
        requestId:
          type: string
          description: Echo in support requests — it indexes the logs
        requiredScope:
          type: string
          description: "403 insufficient_scope: the scope the operation needs."
          nullable: true
        retryAfterSeconds:
          type: integer
          description: "409 idempotency_in_flight and 429: mirrors the Retry-After\
            \ header."
          nullable: true
        status:
          type: integer
        supported:
          type: array
          description: "415: the media types the operation accepts."
          items:
            type: string
          nullable: true
        title:
          type: string
        type:
          type: string
          description: URI ending in the error's catalog slug
      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
        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:
        bankAccountId:
          type: string
          format: uuid
        bankAmountTotal:
          type: number
          description: Snapshot of the bank side at match time.
        bankEntries:
          type: array
          items:
            $ref: "#/components/schemas/BankEntry"
        createdAt:
          type: string
          format: date-time
        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
        note:
          type: string
          nullable: true
        period:
          type: integer
          format: int32
          description: Fiscal period 1-12.
        periodYear:
          type: integer
          format: int32
        stale:
          type: boolean
          description: True when matched data changed after matching (either side).
      required:
      - bankAccountId
      - bankAmountTotal
      - bankEntries
      - createdAt
      - glAmountTotal
      - glEntries
      - id
      - period
      - periodYear
      - stale
    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
    ReconciliationDeletionResult:
      type: object
      description: "Confirmation: the group is dissolved; its transactions and lines\
        \ are unreconciled again."
      properties:
        id:
          type: string
          format: uuid
        status:
          type: string
          enum:
          - deleted
          example: deleted
      required:
      - id
      - status
    ReconciliationSummary:
      type: object
      description: The reconciliation picture for one bank account across a year.
      properties:
        bankAccountId:
          type: string
          format: uuid
        periods:
          type: array
          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
    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
        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."
        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."
        sources:
          type: array
          items:
            $ref: "#/components/schemas/RoutineSource"
        year:
          type: integer
          format: int32
          description: The accounting year the account was resolved in.
      required:
      - accountNumber
      - companyId
      - companyRoutineVersion
      - mapped
      - sources
      - year
    RoutineVersion:
      type: object
      description: One captured version of a routine's text.
      properties:
        changeType:
          type: string
          description: "INSERT, UPDATE or DELETE."
        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."
      properties:
        accountIds:
          type: array
          description: Account ids when accountScope is SPECIFIED; empty otherwise.
          items:
            type: string
            format: uuid
            description: Account ids when accountScope is SPECIFIED; empty otherwise.
        accountScope:
          type: string
          enum:
          - ALL
          - SPECIFIED
          example: ALL
        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
        role:
          type: string
          enum:
          - VIEWER
          - AUDITOR
          - ACCOUNTANT
          - ADMIN
          example: ACCOUNTANT
        scopeType:
          type: string
          description: What the rule covers. PORTFOLIO rules expand to the portfolio's
            current members.
          enum:
          - COMPANY
          - ORGANIZATION
          - PORTFOLIO
          example: COMPANY
      required:
      - accountIds
      - accountScope
      - role
      - scopeType
    RuleInput:
      type: object
      description: One rule of a policy document.
      properties:
        accountIds:
          type: array
          items:
            type: string
            format: uuid
          maxItems: 1000
          nullable: true
        accountScope:
          type: string
          description: "ALL (default) or SPECIFIED, in which case accountIds is required.\
            \ SPECIFIED needs a COMPANY rule."
          enum:
          - ALL
          - SPECIFIED
          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
        role:
          type: string
          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
      required:
      - role
    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 id (or the opening balance's id).
        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
        periodYear:
          type: integer
          format: int32
          nullable: true
        postedDate:
          type: string
          format: date
          nullable: true
        side:
          type: string
          description: debit or credit.
        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
      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.
          example: MONTHLY
        periodYear:
          type: integer
          format: int32
          description: "The period the settlement was made in: year."
        status:
          type: string
          description: "settled (difference below 0.05, rounding) or partial (a remainder\
            \ is left)."
          enum:
          - settled
          - partial
        type:
          type: string
          description: auto (the automatcher) or manual.
          enum:
          - auto
          - manual
      required:
      - accountNumber
      - amount
      - createdAt
      - difference
      - id
      - lines
      - partial
      - period
      - periodType
      - periodYear
      - status
      - type
    Stage:
      type: object
      properties:
        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
        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)."
          nullable: 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
        templateTypes:
          type: array
          description: The account templates the stage rolls up; empty for ar/ap/vat.
          items:
            type: string
            description: The account templates the stage rolls up; empty for ar/ap/vat.
        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.
          nullable: 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"
      required:
      - companyId
      - countryCode
      - data
    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+
        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
        documentId:
          type: string
          description: The source document's id.
        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
        itemId:
          type: string
          format: uuid
          description: Open-item id (what comments on the item refer to).
        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.
        partyKey:
          type: string
          description: The party's sub-ledger key.
        partyName:
          type: string
          description: "The party's register label: \"number: name\", one of the two\
            \ when the other is empty or the same, else the party key."
          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
        subLedgerType:
          type: string
          description: "The sub-ledger type, lower-case (customer, supplier)."
          example: customer
        transactionAmount:
          type: number
          nullable: true
        transactionAmountOpen:
          type: number
          nullable: true
        transactionCurrency:
          type: string
          nullable: true
      required:
      - accountNumber
      - agingBucket
      - amount
      - amountOpen
      - amountOpenAsOf
      - commentCount
      - documentId
      - itemId
      - itemKey
      - open
      - openAsOf
      - partyKey
      - settlementStatus
      - subLedgerType
    SubLedgerParty:
      type: object
      description: One party's cumulative balance in a section; zero balances are
        included.
      properties:
        balance:
          type: number
        partyKey:
          type: string
        partyName:
          type: string
          description: "The party's register label: \"number: name\", one of the two\
            \ when the other is empty or the same, else the party key."
          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
        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: Balances are cumulative through this period; 0 = opening balance
            only.
        sections:
          type: array
          items:
            $ref: "#/components/schemas/SubLedgerSection"
        year:
          type: integer
          format: int32
          description: Accounting year.
      required:
      - companyId
      - ledgerId
      - period
      - sections
      - year
    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: "Untagged balance: controlBalance minus subLedgerBalance."
        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 balance the lines tagged with a party of this type add
            up to.
        subLedgerType:
          type: string
          description: "The sub-ledger type, lower-case (customer, supplier)."
          example: customer
        verdict:
          type: string
          description: "BREAK when differenceAmount or overlapAmount is non-zero at\
            \ two decimals, else BALANCED."
          enum:
          - BALANCED
          - BREAK
      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
        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."
        supported:
          type: boolean
          description: Whether the connected ERP delivers open-item snapshots.
      required:
      - state
      - supported
    SubLedgersImportRequest:
      type: object
      properties:
        subLedgers:
          type: array
          items:
            $ref: "#/components/schemas/MasterLine"
      required:
      - subLedgers
    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
        version:
          type: integer
          format: int32
          description: Policy version; 1 when absent.
          maximum: 1
          minimum: 1
          nullable: true
      required:
      - balanceTolerance
      - checks
      - maxOverdueDays
      - side
    TrialBalanceAccount:
      type: object
      description: "One account's opening balance, monthly movements, and closing\
        \ balance."
      properties:
        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:
      - accountNumber
      - closingBalance
      - openingBalance
      - periods
    TrialBalanceResponse:
      type: object
      description: Trial balance for one accounting year.
      properties:
        accounts:
          type: array
          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).
        totals:
          $ref: "#/components/schemas/TrialBalanceTotals"
        year:
          type: integer
          format: int32
          description: Accounting year.
      required:
      - accounts
      - companyId
      - ledgerId
      - totals
      - year
    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
          nullable: true
        enabled:
          type: boolean
          nullable: true
        expectedVersion:
          type: string
          maxLength: 64
          nullable: true
        matchWindowDays:
          type: integer
          format: int32
          maximum: 365
          minimum: 0
          nullable: true
        reset:
          type: array
          description: Fields to return to the company default.
          items:
            type: string
            enum:
            - enabled
            - matchWindowDays
            - secondPassEnabled
            - autoApprove
          maxItems: 4
          nullable: true
        secondPassEnabled:
          type: boolean
          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
          nullable: true
        fiscalYearStart:
          type: string
          format: date
          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
          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.
          example: MEMBER
        status:
          type: string
          description: Lifecycle state.
          enum:
          - active
          - disabled
          example: active
      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."
      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.
        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
        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
      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
    WebhookEndpointDeletionResult:
      type: object
      description: Confirmation of endpoint deletion.
      properties:
        id:
          type: string
          format: uuid
        status:
          type: string
          enum:
          - deleted
          example: deleted
      required:
      - id
      - status
    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
        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
        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
        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
        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."
      flows:
        clientCredentials:
          scopes:
            access:manage: Manage access policies
            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: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
